k8s部署ingress及http、https-實戰篇

一、簡介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主網頁

ingress #用於監視後端提供服務的端口、定義相關映射及代理規則給Nginx虛擬主機
service及後端服務 #用戶後端pod服務及給Nginx虛擬主機提供被代理對象
組件:
mandatory.yaml #部署ingress-controller
ingress-service.yaml #部署service、後端pod、container
service-nodeport.yaml #暴露端口用於集羣外的客戶端訪問
ingress.yaml #用於定義監聽後端服務及Nginx反代理規則

二、部署七層http
1】定義部署ingress-nginx(ingress-controller)
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yaml

2】定義及部署service、後端pod、container
k8s部署ingress及http、https-實戰篇

3】編輯ingress映射及反代理規則
k8s部署ingress及http、https-實戰篇

注意:ingress中定義的映射規則及策略後續會自動注入到ingress-nginx的虛擬主機中(Nginx配置文件nginx.conf),故可以實現代理訪問

4】定義servicenodeport來暴露端口或服務給互聯網
k8s部署ingress及http、https-實戰篇


kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/baremetal/service-nodeport.yaml
注意:其中的nodePort可以省略,默認使用隨機端口

5】測試
k8s部署ingress及http、https-實戰篇

三、部署七層https
PS:本次使用自定義證書及key
1】創建私鑰
k8s部署ingress及http、https-實戰篇

2】創建證書(本次整爲一行創建)
k8s部署ingress及http、https-實戰篇
PS:CN必須爲訪問的域名相同

3】創建k8s格式試用的secret
k8s部署ingress及http、https-實戰篇

4】編輯ingress映射及反代理規則
k8s部署ingress及http、https-實戰篇
k8s部署ingress及http、https-實戰篇

5】測試
k8s部署ingress及http、https-實戰篇

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章