[root@devops-101 ~]# kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yaml namespace/ingress-nginx created configmap/nginx-configuration created serviceaccount/nginx-ingress-serviceaccount created clusterrole.rbac.authorization.k8s.io/nginx-ingress-clusterrole created role.rbac.authorization.k8s.io/nginx-ingress-role created rolebinding.rbac.authorization.k8s.io/nginx-ingress-role-nisa-binding created clusterrolebinding.rbac.authorization.k8s.io/nginx-ingress-clusterrole-nisa-binding created deployment.extensions/nginx-ingress-controller created [root@devops-101 ~]# kubectl get pods --all-namespaces -l app.kubernetes.io/name=ingress-nginx --watch NAMESPACE NAME READY STATUS RESTARTS AGE ingress-nginx nginx-ingress-controller-664f488479-pr87w 0/1 ContainerCreating 0 5s ingress-nginx nginx-ingress-controller-664f488479-pr87w 0/1 Running 0 11s ingress-nginx nginx-ingress-controller-664f488479-pr87w 1/1 Running 0 16s [root@devops-101 ~]# kubectl get all -n ingress-nginx NAME READY STATUS RESTARTS AGE pod/nginx-ingress-controller-664f488479-pr87w 1/1 Running 0 2m
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE deployment.apps/nginx-ingress-controller 1 1 1 1 2m
NAME DESIRED CURRENT READY AGE replicaset.apps/nginx-ingress-controller-664f488479 1 1 1 2m
[root@devops-101 ~]# kubectl apply -f ingress-install.yaml namespace/nginx-ingress created serviceaccount/nginx-ingress created secret/default-server-secret created configmap/nginx-config created clusterrole.rbac.authorization.k8s.io/nginx-ingress configured clusterrolebinding.rbac.authorization.k8s.io/nginx-ingress configured deployment.extensions/nginx-ingress created [root@devops-101 ~]# kubectl get pods -n nginx-ingress NAME READY STATUS RESTARTS AGE nginx-ingress-767cc6477f-flj2f 1/1 Running 5 4m
实例
没有规则配置的时候,对于所有的请求默认都返回404状态。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
[root@devops-101 ~]# kubectl apply -f cafe-example.yaml deployment.extensions/coffee created service/coffee-svc created deployment.extensions/tea created service/tea-svc created secret/cafe-secret created ingress.extensions/cafe-ingress created [root@devops-101 ~]# IC_IP=192.168.0.102 [root@devops-101 ~]# IC_HTTPS_PORT=31586 [root@devops-101 ~]# curl --resolve cafe.example.com:$IC_HTTPS_PORT:$IC_IP https://cafe.example.com:$IC_HTTPS_PORT/tea --insecure Server address: 172.16.1.138:80 Server name: tea-7d57856c44-jxpvt Date: 22/Oct/2018:11:37:47 +0000 URI: /tea Request ID: 796e79e0280a27743cb682b8e893d6e9