您的位置:首页 > 运维架构 > Nginx

kubernetes ingress-nginx 0.15.0使用

2018-06-04 16:50 423 查看
版权声明:本博客文章为作者原创,转载请注明参考文献地址 https://blog.csdn.net/zhangoic/article/details/80569579

1 创建相关资源

# kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yaml

此时ingress-nginx-controller还不能使用,container日志显示缺少ingress-nginx服务。

2 创建ingress-nginx服务

# kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/baremetal/service-nodeport.yaml

3 测试

# kubectl get svc  -o wide -n ingress-nginx
NAME                   TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE       SELECTOR
default-http-backend   ClusterIP   10.104.183.167   <none>        80/TCP         1h        app=default-http-backend
ingress-nginx          NodePort    10.108.244.205   <none>        80:32483/TCP   52m       app=ingress-nginx

# cat << EOF | kubectl create -f -
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: hello-world-deployment
spec:
replicas: 1
template:
metadata:
labels:
app: hello-world
spec:
containers:
- image: "gokul93/hello-world:latest"
imagePullPolicy: Always
name: hello-world-container
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: hello-world-svc
spec:
ports:
-  port: 8080
protocol: TCP
targetPort: 8080
selector:
app: hello-world
type: NodePort
EOF

# cat << EOF | kubectl create -f -
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
creationTimestamp: 2018-08-03T02:51:13Z
generation: 2
name: hello-world-ingress
namespace: default
resourceVersion: "3668608"
selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/hello-world-ingress
uid: 15b9c53b-96c8-11e8-9920-00505683568f
spec:
rules:
- http:
paths:
- backend:
serviceName: hello-world-svc
servicePort: 8080
path: /
EOF

# curl k8s-node-ip:32483/hello
Hello world!hello
阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: