1、簡介ingress:
ingress-nginx #用於實現反代
https://kubernetes.github.io/ingress-nginx/deploy/#generic-deployment
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yaml
https://kubernetes.github.io/ingress-nginx/deploy/ #k8s部署ingress主網頁node
ingress #用於監視後端提供服務的端口、定義相關映射及代理規則給Nginx虛擬主機
service及後端服務 #用戶後端pod服務及給Nginx虛擬主機提供被代理對象
組件:
mandatory.yaml #部署ingress-controller
ingress-service.yaml #部署service、後端pod、container
service-nodeport.yaml #暴露端口用於集羣外的客戶端訪問
ingress.yaml #用於定義監聽後端服務及Nginx反代理規則nginx
2、部署七層http
1】定義部署ingress-nginx(ingress-controller)
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yamlgit
2】定義及部署service、後端pod、containergithub
3】編輯ingress映射及反代理規則後端
注意:ingress中定義的映射規則及策略後續會自動注入到ingress-nginx的虛擬主機中(Nginx配置文件nginx.conf),故能夠實現代理訪問app
4】定義servicenodeport來暴露端口或服務給互聯網ide
或
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/baremetal/service-nodeport.yaml
注意:其中的nodePort能夠省略,默認使用隨機端口測試
5】測試代理
3、部署七層https
PS:本次使用自定義證書及key
1】建立私鑰對象
2】建立證書(本次整爲一行建立)
PS:CN必須爲訪問的域名相同
3】建立k8s格式試用的secret
4】編輯ingress映射及反代理規則
5】測試