k8s ingress 暴露埠的方式

2022-08-22 22:00:14 字數 1041 閱讀 4618

ingress與ingress-controller

ingress分為兩個概念,ingress和ingress-controller

ingress:指的是k8s中的乙個api物件,一般用yaml配置,作用是定義請求如何**到service的規則,也就是配置的規則

ingress-controller:乙個容器,容器中執行著負載均衡的程式,比如ingress-nginx、ingress-haproxy。ingress-controller會對ingress定義的規則進行解析,根據配置的規則來實現請求**。

ingress常見的部署正規化

1. deployment+loadbalancer模式的service

這中方式適合在公有雲,用deployment部署ingress-controller,建立乙個type為loadbalancer的service關聯這組pod

2. deployment+nodeport模式的service

同樣用deployment模式部署ingress-controller,並建立對應的服務,但是type為nodeport。這樣,ingress就會暴露在集群節點ip的特定埠上。由於nodeport暴露的埠是隨機埠,一般會在前面再搭建一套負載均衡器來**請求

用daemonset結合nodeselector來部署ingress-controller到特定的node上,然後使用hostnetwork直接把該pod與宿主機node的網路打通,直接使用宿主機的80/433埠就能訪問服務。

參考文件

k8s ingress配置websocket支援

問題分析 表現形式 websocket鏈結 報錯 200 1copywebsocket connection to ws faile error during websocket handshake unexpected response code 200 猜測引起原因以及應對方式 解決方案 由於k...

k8s ingress配置websocket支援

具體來說,使用的ingress controller不一樣,有關的設定也不太一樣 參考 在 nginx ingress controller 中預設已經支援websocket訪問,官方文件中說明websocket不需要特別的配置,但需要在註解中配置以下三項 網上看到的另一種寫法配置 沒實踐過,若是配...

前後端分離架構 k8s ingress

接下來使用k8s進行發布應用 k8s集群 系統docker ip主機名 配置centos 7.6 19.03.5 192.168.31.150 k8s master 2核4g centos 7.6 19.03.5 192.168.31.178 k8s node01 2核4g centos 7.6 1...