跳到主要内容
版本:v2.6

端口要求

为了确保能正常运行,Rancher 需要在 Rancher 节点和下游 Kubernetes 集群节点上开放一些端口。

Rancher 节点

下表列出了运行 Rancher Server 的节点之间需要开放的端口。

不同的 Rancher Server 架构有不同的端口要求。

Rancher 可以安装在任何 Kubernetes 集群上。如果你的 Rancher 安装在 K3s、RKE 或 RKE2 Kubernetes 集群上,请参考下面的标签页。对于其他 Kubernetes 发行版,请参见该发行版的文档,了解集群节点的端口要求。

注意事项:
  • Rancher 节点可能要求额外出站访问已配置的外部验证提供程序(如 LDAP)。
  • Kubernetes 建议节点端口服务使用 TCP 30000-32767。
  • 对于防火墙,可能需要在集群和 Pod CIDR 内启用流量。
  • Rancher 节点可能还需要出站访问用于存储集群备份(如 Minio)的外部 S3 上的位置。

K3s 上 Rancher Server 节点的端口

单击展开

K3s server 需要开放端口 6443 才能供节点访问。

使用 Flannel VXLAN 时,节点需要能够通过 UDP 端口 8472 访问其他节点。节点不应监听任何其他端口。K3s 使用反向隧道,建立节点与 Server 的出站连接,所有 kubelet 流量都通过该隧道进行。但是,如果你不使用 Flannel,而是使用自定义的 CNI,K3s 则不需要打开 8472 端口。

如果要使用 Metrics Server,则需要在每个节点上打开端口 10250。

重要提示:

节点上的 VXLAN 端口会开放集群网络,让任何人均能访问集群。因此,不要将 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 catalog
TCP2376使用 Node Driver 创建的节点的任何节点 IPDocker Machine 使用的 Docker daemon TLS 端口
TCP6443托管/导入的 Kubernetes APIKubernetes API Server

RKE 上 Rancher Server 节点的端口

单击展开

通常情况下,Rancher 安装在三个 RKE 节点上,这些节点都有 etcd、controlplane 和 worker 角色。

下表描述了 Rancher 节点之间流量的端口要求:

Rancher 节点的流量规则
协议端口描述
TCP443Rancher Agents
TCP2379etcd 客户端请求
TCP2380etcd 对等通信
TCP6443Kubernetes apiserver
TCP8443NGINX Ingress 的验证 Webhook
UDP8472Canal/Flannel VXLAN 覆盖网络
TCP9099Canal/Flannel livenessProbe/readinessProbe
TCP10250Metrics Server 与所有节点的通信
TCP10254Ingress controller livenessProbe/readinessProbe

下表描述了入站和出站流量的端口要求:

Rancher 节点的入站规则
协议端口描述
TCP22RKE CLIRKE 通过 SSH 配置节点
TCP80负载均衡器/反向代理到 Rancher UI/API 的 HTTP 流量
TCP443
  • 负载均衡器/反向代理
  • 所有集群节点和其他 API/UI 客户端的 IP
到 Rancher UI/API 的 HTTPS 流量
TCP6443Kubernetes API 客户端到 Kubernetes API 的 HTTPS 流量
Rancher 节点的出站规则
协议端口目标描述
TCP443git.rancher.ioRancher catalog
TCP22使用 Node Driver 创建的任何节点Node Driver 通过 SSH 配置节点
TCP2376使用 Node Driver 创建的任何节点Node Driver 使用的 Docker daemon TLS 端口
TCP6443托管/导入的 Kubernetes APIKubernetes API Server
TCP提供商依赖托管集群中 Kubernetes API 端点的端口Kubernetes API

RKE2 上 Rancher Server 节点的端口

单击展开

RKE2 server 需要开放端口 6443 和 9345 才能供集群中的其他节点访问。

使用 Flannel VXLAN 时,所有节点都需要能够通过 UDP 端口 8472 访问其他节点。

如果要使用 Metrics Server,则需要在每个节点上打开端口 10250。

重要提示:

节点上的 VXLAN 端口会开放集群网络,让任何人均能访问集群。因此,不要将 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
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 catalog
TCP2376使用 Node Driver 创建的节点的任何节点 IPDocker Machine 使用的 Docker daemon TLS 端口
TCP6443托管/导入的 Kubernetes APIKubernetes API Server

下游 Kubernetes 集群节点

下游 Kubernetes 集群用于运行你的应用和服务。本节介绍了哪些端口需要在下游集群的节点上打开,以便 Rancher 能够与它们进行通信。

不同的下游集群的启动方式有不同的端口要求。下面的每个标签都列出了不同集群类型所需打开的端口。

下图描述了为每个集群类型打开的端口。

Rancher 管理面板的端口要求

基本端口要求

提示

如果你对安全性的关注不是太高,而且也愿意多打开几个端口,你可以参考常用端口中列出的端口,而不是参考下方的表格。

Rancher 使用节点池启动 Kubernetes 集群的端口

单击展开

下表描述了节点在云提供商中创建的情况下,Rancher 启动 Kubernetes 的端口要求。

备注

在 AWS 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 2.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 节点上打开。

协议端口描述
TCP22Node Driver SSH 配置
TCP179Calico BGP 端口
TCP2376Node Driver Docker daemon TLS 端口
TCP2379etcd 客户端请求
TCP2380etcd 对等通信
UDP8472Canal/Flannel VXLAN 覆盖网络
UDP4789Windows 集群中的 Flannel VXLAN 覆盖网络
TCP8443Rancher webhook
TCP9099Canal/Flannel livenessProbe/readinessProbe
TCP9100Monitoring 从 Linux node-exporter 中抓取指标所需的默认端口
TCP9443Rancher webhook
TCP9796Monitoring 从 Windows node-exporter 中抓取指标所需的默认端口
TCP6783Weave 端口
UDP6783-6784Weave UDP 端口
TCP10250Metrics Server 与所有节点 API 的通信
TCP10254Ingress controller livenessProbe/readinessProbe
TCP/UDP30000-32767NodePort 端口范围

本地节点流量

上述要求中标记为本地流量(例如 9099 TCP)的端口会用于 Kubernetes 健康检查 (livenessProbereadinessProbe)。 这些健康检查是在节点本身执行的。在大多数云环境中,这种本地流量是默认允许的。

但是,在以下情况下可能会阻止此流量:

  • 你已在节点上应用了严格的主机防火墙策略。
  • 你正在使用有多个接口(多宿主)的节点。

在这些情况下,你必须在你的主机防火墙中主动允许这种流量,如果是公共/私有云托管的主机(例如 AWS 或 OpenStack),你需要在你的安全组配置中主动允许此流量。请记住,如果你在安全组中使用安全组作为源或目标,主动开放端口只适用于节点/实例的私有接口。

Rancher AWS EC2 安全组

当你使用 AWS EC2 Node Driver 在 Rancher 中配置集群节点时,你可以让 Rancher 创建一个名为 rancher-nodes 的安全组。以下规则会自动添加到该安全组中。

类型协议端口范围源/目标规则类型
SSHTCP220.0.0.0/0入站
HTTPTCP800.0.0.0/0入站
自定义 TCP 规则TCP4430.0.0.0/0入站
自定义 TCP 规则TCP23760.0.0.0/0入站
自定义 TCP 规则TCP2379-2380sg-xxx (rancher-nodes)入站
自定义 UDP 规则UDP4789sg-xxx (rancher-nodes)入站
自定义 TCP 规则TCP64430.0.0.0/0入站
自定义 UDP 规则UDP8472sg-xxx (rancher-nodes)入站
自定义 TCP 规则TCP10250-10252sg-xxx (rancher-nodes)入站
自定义 TCP 规则TCP10256sg-xxx (rancher-nodes)入站
自定义 TCP 规则TCP30000-327670.0.0.0/0入站
自定义 UDP 规则UDP30000-327670.0.0.0/0入站
所有流量全部全部0.0.0.0/0出站

打开 SUSE Linux 端口

SUSE Linux 可能有一个防火墙,默认情况下会阻止所有端口。要打开将主机添加到自定义集群所需的端口:

  1. SSH 进入实例。

  2. 以文本模式启动 YaST:

    sudo yast2
  3. 导航到安全和用户 > 防火墙 > 区域:公共 > 端口。要在界面内导航,请参照说明

  4. 要打开所需的端口,把它们输入到 TCP 端口UDP 端口 字段。在这个例子中,端口 9796 和 10250 也被打开,用于监控。由此产生的字段应类似于以下内容:

    TCP Ports
    22, 80, 443, 2376, 2379, 2380, 6443, 9099, 9796, 10250, 10254, 30000-32767
    UDP Ports
    8472, 30000-32767
  5. 所有必须端口都输入后,选择接受

结果 :该节点已打开添加到自定义集群所需的端口。