资源下载
IngressController
IngressYAML

Ingress安装部署
#1.将下载的ingress.tar.gz通过docker的方式导入harbor仓库[root@master ingress]# docker load -i ingress.tar.xz[root@master ingress]# docker images|while read i t _;do[[ "${t}" == "TAG" ]] && continue[[ "${i}" =~ ^"harbor:443/".+ ]] && continuedocker tag ${i}:${t} harbor:443/plugins/${i##*/}:${t}docker push harbor:443/plugins/${i##*/}:${t}docker rmi ${i}:${t} harbor:443/plugins/${i##*/}:${t}done#2.修改YAML文件,YAML文件中的仓库根据自己仓库地址修改[root@master ingress]# sed -ri 's,^(\s*image: )(.*/)?(.+)@.*,\1harbor:443/plugins/\3,' deploy.yaml458:image: harbor:443/plugins/controller:v1.5.1565:image: harbor:443/plugins/kube-webhook-certgen:v20220916-gd32f8c343614:image: harbor:443/plugins/kube-webhook-certgen:v20220916-gd32f8c343#3.应用yaml文件[root@master ingress]# kubectl apply -f deploy.yaml# 通过标签指定在那台机器上发布应用[root@master ingress]# kubectl label nodes node-0001 ingress-ready="true"node/node-0001 labeled#4.验证后端服务[root@master ingress]# kubectl -n ingress-nginx get podsNAMEREADY STATUSRESTARTSingress-nginx-admission-create--1-lm52c 0/1 Completed 0ingress-nginx-admission-patch--1-sj2lz0/1 Completed 0ingress-nginx-controller-5664857866-tql24 1/1 Running 0[root@master ~]# kubectl get pods,services NAME READY STATUSRESTARTS AGEpod/web1 1/1 Running 035mNAME TYPECLUSTER-IPEXTERNAL-IP PORT(S)service/kubernetes ClusterIP 10.245.0.1<none>443/TCPservice/mysvcClusterIP 10.245.1.80 <none>80/TCPservice/mysvc1 NodePort10.245.1.88 <none>80:30080/TCP[root@master ~]# curl http://10.245.1.80Welcome to The Apache.# 5.对外发布服务[root@master ~]# kubectl get ingressclasses.networking.k8s.io NAMECONTROLLER PARAMETERS AGEnginx k8s.io/ingress-nginx <none> 5m7s# 资源对象模板[root@master ~]# kubectl create ingress mying --class=nginx --rule=nsd.tedu.cn/*=mysvc:80 --dry-run=client -o yaml[root@master ~]# vim mying.yaml---kind: IngressapiVersion: networking.k8s.io/v1metadata:name: myingspec:ingressClassName: nginxrules:- host: nsd.tedu.cnhttp:paths:- path: /pathType: Prefixbackend:service:name: mysvcport:number: 80[root@master ~]# kubectl apply -f mying.yaml ingress.networking.k8s.io/mying created[root@master ~]# kubectl get ingressNAMECLASS HOSTS ADDRESSPORTSmying nginx nsd.tedu.cn 192.168.1.51 80[root@master ~]# curl -H "Host: nsd.tedu.cn" http://192.168.1.51Welcome to The Apache.