环境
- 部署nginx ingress
wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.10.1/deploy/static/provider/cloud/deploy.yaml
grep image: deploy.yaml
sed -i 's#registry.k8s.io/ingress-nginx/controller:v1.10.1@sha256:e24f39d3eed6bcc239a56f20098878845f62baa34b9f2be2fd2c38ce9fb0f29e#registry.cn-hangzhou.aliyuncs.com/ylqer/ingress-nginx-controller:v1.10.1#' deploy.yaml
sed -i 's#registry.k8s.io/ingress-nginx/kube-webhook-certgen:v1.4.1@sha256:36d05b4077fb8e3d13663702fa337f124675ba8667cbd949c03a8e8ea6fa4366#registry.cn-hangzhou.aliyuncs.com/ylqer/ingress-nginx-kube-webhook-certgen:v1.4.1#' deploy.yaml
sed -i 's#externalTrafficPolicy: Local#externalTrafficPolicy: Cluster#' deploy.yaml
externalIPs: ['192.168.10.134']
kubectl apply -f deploy.yaml
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/88bf8b526dcc406a96504f6b5e88ac7f.png)
- 部署测试pod和service
kubectl create deployment pod-test1 --image=wangxiaochun/pod-test:v0.1 --replicas=3
kubectl create deployment pod-test2 --image=wangxiaochun/pod-test:v0.2 --replicas=3
kubectl create service clusterip pod-test1 --tcp=80:80
kubectl create service clusterip pod-test2 --tcp=80:80
kubectl create ingress demo-ingress --rule="www.ylq.org/=pod-test1:80" --class=nginx
ping www.ylq.org