跳至主要内容

連接埠需求

為了正常運作,Rancher 需要在 Rancher 節點和下游 Kubernetes 叢集節點上開啟許多連接埠。

Rancher 節點​

下表列出了執行 Rancher server 的節點需要開啟的連接埠(進出)。

連接埠需求因 Rancher server 架構而異。

Rancher 可以安裝在任何 Kubernetes 叢集上。對於在 K3s 或 RKE2 Kubernetes 叢集上安裝 Rancher,請參閱下面的標籤。對於其他 Kubernetes 發行版,請參閱該發行版的文件以了解叢集節點的連接埠需求。

注意:
  • Rancher 節點可能還需要額外的出站存取權限,以連線到配置的任何外部認證提供者(例如 LDAP)。
  • Kubernetes 建議 TCP 30000-32767 用於 node port 服務。
  • 對於防火牆,可能需要在叢集和 Pod CIDR 內啟用流量。
  • Rancher 節點可能還需要出站存取權限,以連線到用於儲存叢集備份的外部 S3 位置(例如 Minio)。

K3s 上 Rancher Server 節點的連接埠​

點擊展開

K3s server 需要連接埠 6443 可被節點存取。

當使用 Flannel VXLAN 時,節點需要能夠透過 UDP 連接埠 8472 連線到其他節點。節點不應該監聽任何其他連接埠。K3s 使用反向隧道,使節點對伺服器進行出站連線,所有 kubelet 流量都透過該隧道執行。然而,如果你不使用 Flannel 並提供自己的自訂 CNI,則 K3s 不需要連接埠 8472。

如果你希望使用 metrics server,則需要在每個節點上開啟連接埠 10250。

重要:

節點上的 VXLAN 連接埠不應該暴露給外界,因為它會讓任何人都可以存取你的叢集網路。在防火牆/安全群組後面執行你的節點,以停用對連接埠 8472 的存取。

下表列出了入站和出站流量的連接埠需求:

Rancher Server 節點的入站規則
協定連接埠來源說明
TCP80執行外部 SSL 終止的負載平衡器/代理使用外部 SSL 終止時的 Rancher UI/API
TCP443
  • server 節點
  • agent 節點
  • 託管/註冊的 Kubernetes
  • 任何需要能夠使用 Rancher UI 或 API 的來源
Rancher agent、Rancher UI/API、kubectl
TCP6443K3s server 節點Kubernetes API
UDP8472K3s server 和 agent 節點僅當使用 Flannel VXLAN 時需要。
TCP10250K3s server 和 agent 節點kubelet
Rancher 節點的出站規則
協定連接埠目的地說明
TCP22使用 Node Driver 建立的任何節點 IP使用 Node Driver 進行節點的 SSH 佈建
TCP443git.rancher.ioRancher 目錄
TCP2376使用 Node driver 建立的任何節點 IPDocker Machine 使用的 Docker daemon TLS 連接埠
TCP6443託管/匯入的 Kubernetes APIKubernetes API server

RKE2 上 Rancher Server 節點的連接埠​

點擊展開

RKE2 server 需要連接埠 6443 和 9345 可被叢集中的其他節點存取。

當使用 Flannel VXLAN 時,所有節點都需要能夠透過 UDP 連接埠 8472 連線到其他節點。

如果你希望使用 metrics server,則需要在每個節點上開啟連接埠 10250。

重要:

節點上的 VXLAN 連接埠不應該暴露給外界,因為它會讓任何人都可以存取你的叢集網路。在防火牆/安全群組後面執行你的節點,以停用對連接埠 8472 的存取。

RKE2 Server 節點的入站規則
協定連接埠來源說明
TCP9345RKE2 server 和 agent 節點節點註冊。連接埠應該在所有 server 節點上對叢集中的所有其他節點開放。
TCP6443RKE2 agent 節點Kubernetes API
UDP8472RKE2 server 和 agent 節點僅當使用 Flannel VXLAN 時需要
TCP10250RKE2 server 和 agent 節點kubelet
TCP2379RKE2 server 節點etcd 用戶端連接埠
TCP2380RKE2 server 節點etcd 對等連接埠
TCP30000-32767RKE2 server 和 agent 節點NodePort 連接埠範圍。可以使用 TCP 或 UDP。
TCP5473Calico-node Pod 連線到 typha Pod使用 Calico 部署時需要
HTTP80執行外部 SSL 終止的負載平衡器/代理使用外部 SSL 終止時的 Rancher UI/API
HTTPS443
  • 託管/註冊的 Kubernetes
  • 任何需要能夠使用 Rancher UI 或 API 的來源
Rancher agent、Rancher UI/API、kubectl。如果你有負載平衡器執行 TLS 終止,則不需要。

通常允許所有出站流量。

Docker 中 Rancher Server 的連接埠​

點擊展開

下表列出了 Rancher 節點的連接埠需求,包括入站和出站流量:

Rancher 節點的入站規則
協定連接埠來源說明
TCP80執行外部 SSL 終止的負載平衡器/代理使用外部 SSL 終止時的 Rancher UI/API
TCP443
  • 託管/註冊的 Kubernetes
  • 任何需要能夠使用 Rancher UI 或 API 的來源
Rancher agent、Rancher UI/API、kubectl
Rancher 節點的出站規則
協定連接埠來源說明
TCP22使用 Node Driver 建立的任何節點 IP使用 Node Driver 進行節點的 SSH 佈建
TCP443git.rancher.ioRancher 目錄
TCP2376使用 Node driver 建立的任何節點 IPDocker Machine 使用的 Docker daemon TLS 連接埠
TCP6443託管/匯入的 Kubernetes APIKubernetes API server

下游 Kubernetes 叢集節點​

下游 Kubernetes 叢集執行你的應用程式和服務。本節描述需要在下游叢集的節點上開啟哪些連接埠,以便 Rancher 可以與它們通訊。

連接埠需求因下游叢集的啟動方式而異。下面的每個標籤都列出了不同叢集類型需要開啟的連接埠。

下圖描繪了每種叢集類型開啟的連接埠。

Rancher 管理平面的連接埠需求

基本連接埠需求

提示

如果安全性不是主要問題,並且你可以開啟一些額外的連接埠,你可以使用常用連接埠表格作為連接埠參考,而不是下面的詳細表格。

Harvester 叢集的連接埠​

有關 Harvester 連接埠需求的更多資訊,請參閱 Harvester 整合概述。

使用節點池啟動的 Rancher Kubernetes 叢集的連接埠​

點擊展開

下表描繪了使用在基礎架構提供商中建立的節點啟動的 Rancher Kubernetes 的連接埠需求。

備註

在雲端提供商(如 Amazon EC2 或 DigitalOcean)中建立叢集期間,Rancher 會自動開啟所需的連接埠。

From / ToRancher Nodesetcd Plane NodesControl Plane NodesWorker Plane NodesExternal Rancher Load BalancerInternet
Rancher Nodes (1)22 TCPgit.rancher.io
2376 TCP
etcd Plane Nodes443 TCP (3)2379 TCP443 TCP
2380 TCP
6443 TCP
8472 UDP
9099 TCP (4)
Control Plane Nodes443 TCP (3)2379 TCP443 TCP
2380 TCP
6443 TCP
8472 UDP
10250 TCP
9099 TCP (4)
10254 TCP (4)
Worker Plane Nodes443 TCP (3)6443 TCP443 TCP
8472 UDP
9099 TCP (4)
10254 TCP (4)
Kubernetes API Clients6443 TCP (5)
Workload Clients or Load Balancer30000-32767 TCP / UDP
(nodeport)
80 TCP (Ingress)
443 TCP (Ingress)
Notes:

1. Nodes running standalone server or Rancher HA deployment.
2. Required to fetch Rancher chart library.
3. Only without external load balancer in front of Rancher.
4. Local traffic to the node itself (not across nodes).
5. Only if Authorized Cluster Endpoints are activated.

使用自訂節點啟動的 Rancher Kubernetes 叢集的連接埠​

點擊展開

下表描繪了使用自訂節點啟動的 Rancher Kubernetes 的連接埠需求。

From / ToRancher Nodesetcd Plane NodesControl Plane NodesWorker Plane NodesExternal Rancher Load BalancerInternet
Rancher Nodes (1)git.rancher.io
etcd Plane Nodes443 TCP (3)2379 TCP443 TCP
2380 TCP
6443 TCP
8472 UDP
4789 UDP (6)
9099 TCP (4)
Control Plane Nodes443 TCP (3)2379 TCP443 TCP
2380 TCP
6443 TCP
8472 UDP
4789 UDP (6)
10250 TCP
9099 TCP (4)
10254 TCP (4)
Worker Plane Nodes443 TCP (3)6443 TCP443 TCP
8472 UDP
4789 UDP (6)
9099 TCP (4)
10254 TCP (4)
Kubernetes API Clients6443 TCP (5)
Workload Clients or Load Balancer30000-32767 TCP / UDP
(nodeport)
80 TCP (Ingress)
443 TCP (Ingress)
Notes:

1. Nodes running standalone server or Rancher HA deployment.
2. Required to fetch Rancher chart library.
3. Only without external load balancer in front of Rancher.
4. Local traffic to the node itself (not across nodes), if you've enabled optional features such as Rancher Monitoring.
5. Only if Authorized Cluster Endpoints are activated.
6. Only if using Overlay mode on Windows cluster.

託管 Kubernetes 叢集的連接埠​

點擊展開

下表描繪了託管叢集的連接埠需求。

From / ToRancher NodesHosted / Imported ClusterExternal Rancher Load BalancerInternet
Rancher Nodes (1)80 TCPKubernetes API
Endpoint Port (2)
git.rancher.io
8443 TCP
9443 TCP
Hosted / Imported Cluster443 TCP (4)(5)443 TCP (5)
Kubernetes API ClientsCluster / Provider Specific (6)
Workload ClientCluster / Provider Specific (7)
Notes:

1. Nodes running standalone server or Rancher HA deployment.
2. Only for hosted clusters.
3. Required to fetch Rancher chart library.
4. Only without external load balancer.
5. From worker nodes.
6. For direct access to the Kubernetes API without Rancher.
7. Usually Ingress backed by infrastructure load balancer and/or nodeport.

註冊叢集的連接埠​

備註

在 Rancher v2.5 之前,註冊叢集稱為匯入叢集。

點擊展開

下表描繪了註冊叢集的連接埠需求。

From / ToRancher NodesHosted / Imported ClusterExternal Rancher Load BalancerInternet
Rancher Nodes (1)80 TCPKubernetes API
Endpoint Port (2)
git.rancher.io
8443 TCP
9443 TCP
Hosted / Imported Cluster443 TCP (4)(5)443 TCP (5)
Kubernetes API ClientsCluster / Provider Specific (6)
Workload ClientCluster / Provider Specific (7)
Notes:

1. Nodes running standalone server or Rancher HA deployment.
2. Only for hosted clusters.
3. Required to fetch Rancher chart library.
4. Only without external load balancer.
5. From worker nodes.
6. For direct access to the Kubernetes API without Rancher.
7. Usually Ingress backed by infrastructure load balancer and/or nodeport.

其他連接埠考量​

常用連接埠​

無論是什麼類型的叢集,這些連接埠通常會在你的 Kubernetes 節點上開啟。

協定埠號說明
TCP22節點驅動程式 SSH 佈建
TCP179Calico BGP 埠
TCP2376節點驅動程式 Docker daemon TLS 埠
TCP2379etcd 用戶端請求
TCP2380etcd 對等通訊
UDP8472Canal/Flannel VXLAN 覆蓋網路
UDP4789Windows 叢集上的 Flannel VXLAN 覆蓋網路
TCP8443Rancher webhook
TCP9099Canal/Flannel livenessProbe/readinessProbe
TCP9443Rancher webhook
TCP9796監控從 Linux 和 Windows node-exporters 抓取指標所需的預設埠
TCP6783Weave 埠
UDP6783-6784Weave UDP 埠
TCP10250Metrics server 與所有節點 API 的通訊
TCP10254Ingress controller livenessProbe/readinessProbe
TCP/UDP30000-32767NodePort 埠範圍

本機節點流量​

上述需求中標記為 local traffic(即 9099 TCP)的連接埠用於 Kubernetes 健康檢查(livenessProbe 和 readinessProbe)。 這些健康檢查在節點本身上執行。在大多數雲端環境中,預設允許此本機流量。

然而,此流量可能在以下情況下被阻止:

  • 你在節點上應用了嚴格的主機防火牆策略。
  • 你使用具有多個介面(多宿主)的節點。

在這些情況下,你必須在主機防火牆中明確允許此流量,或者在公共/私有雲託管機器(例如 AWS 或 OpenStack)的情況下,在安全群組配置中明確允許。請記住,當使用安全群組作為安全群組中的來源或目的地時,明確開啟連接埠僅適用於節點/實例的私有介面。

Rancher AWS EC2 安全群組​

當使用 AWS EC2 節點驅動程式在 Rancher 中佈建叢集節點時,你可以選擇讓 Rancher 建立一個名為 rancher-nodes 的安全群組。以下規則會自動新增到此安全群組。

類型協定連接埠範圍來源/目的地規則類型
SSHTCP220.0.0.0/0 和 ::/0入站
HTTPTCP800.0.0.0/0 和 ::/0入站
Custom TCP RuleTCP4430.0.0.0/0 和 ::/0入站
Custom TCP RuleTCP23760.0.0.0/0 和 ::/0入站
Custom TCP RuleTCP64430.0.0.0/0 和 ::/0入站
Custom TCP RuleTCP179sg-xxx (rancher-nodes)入站
Custom TCP RuleTCP9345sg-xxx (rancher-nodes)入站
Custom TCP RuleTCP2379-2380sg-xxx (rancher-nodes)入站
Custom TCP RuleTCP10250-10252sg-xxx (rancher-nodes)入站
Custom TCP RuleTCP10256sg-xxx (rancher-nodes)入站
Custom UDP RuleUDP4789sg-xxx (rancher-nodes)入站
Custom UDP RuleUDP8472sg-xxx (rancher-nodes)入站
Custom TCP RuleTCP30000-327670.0.0.0/0 和 ::/0入站
Custom UDP RuleUDP30000-327670.0.0.0/0 和 ::/0入站
All trafficAllAll0.0.0.0/0 和 ::/0出站

開啟 SUSE Linux 連接埠​

SUSE Linux 可能有一個預設阻止所有連接埠的防火牆。要開啟將主機新增到自訂叢集所需的連接埠,

  1. SSH 進入實例。

  2. 以文字模式啟動 YaST:

    sudo yast2
  3. 導覽至 Security and Users > Firewall > Zones:public > Ports。要在介面中導覽,請遵循這些說明。

  4. 要開啟所需的連接埠,將它們輸入到 TCP Ports 和 UDP Ports 欄位中。在此範例中,還開啟了連接埠 9796 和 10250 用於監控。結果欄位應該類似於以下內容:

    TCP Ports
    22, 80, 443, 2376, 2379, 2380, 6443, 9099, 9796, 10250, 10254, 30000-32767
    UDP Ports
    8472, 30000-32767
  5. 當所有必需的連接埠都輸入後,選擇 Accept。

**結果:**節點具有新增到自訂叢集所需的開放連接埠。