1.7. 使用平台"none"选项对集群的要求
本节介绍了配置为使用平台 none
选项的基于 Agent 的 OpenShift Container Platform 安装的要求。
在尝试在虚拟化或云环境中安装 OpenShift Container Platform 集群前,请参阅有关在未经测试的平台上部署 OpenShift Container Platform 的指南 中的信息。
1.7.1. 平台"none" DNS 要求
在 OpenShift Container Platform 部署中,以下组件需要 DNS 名称解析:
- The Kubernetes API
- OpenShift Container Platform 应用程序通配符
- control plane 和计算机器
Kubernetes API、control plane 机器和计算机器还需要反向 DNS 解析。
DNS A/AAAA 或 CNAME 记录用于名称解析,PTR 记录用于反向名称解析。反向记录很重要,因为 Red Hat Enterprise Linux CoreOS(RHCOS)使用反向记录为所有节点设置主机名,除非 DHCP 提供主机名。另外,反向记录用于生成 OpenShift Container Platform 需要操作的证书签名请求(CSR)。
建议使用 DHCP 服务器为每个群集节点提供主机名。
使用 platform none
选项的 OpenShift Container Platform 集群需要以下 DNS 记录,且必须在安装前就位它们。在每个记录中,<cluster_name>
是集群名称,<base_domain>
是您在 install-config.yaml
文件中指定的基域。完整的 DNS 记录采用以下形式: <component>.<cluster_name>.<base_domain>.
。
组件 | 记录 | 描述 |
---|---|---|
Kubernetes API |
| DNS A/AAAA 或 CNAME 记录,以及用于标识 API 负载均衡器的 DNS PTR 记录。这些记录必须由集群外的客户端和集群中的所有节点解析。 |
| DNS A/AAAA 或 CNAME 记录,以及用于内部标识 API 负载均衡器的 DNS PTR 记录。这些记录必须可以从集群中的所有节点解析。 重要 API 服务器必须能够根据 Kubernetes 中记录的主机名解析 worker 节点。如果 API 服务器无法解析节点名称,则代理的 API 调用会失败,且您无法从 pod 检索日志。 | |
Routes |
| 通配符 DNS A/AAAA 或 CNAME 记录,指向应用程序入口负载均衡器。应用程序入口负载均衡器以运行 Ingress Controller Pod 的机器为目标。默认情况下,Ingress Controller Pod 在计算机器上运行。这些记录必须由集群外的客户端和集群中的所有节点解析。
例如,console |
control plane 机器 |
| DNS A/AAAA 或 CNAME 记录,以识别 control plane 节点的每台机器。这些记录必须由集群中的节点解析。 |
计算机器 |
| DNS A/AAAA 或 CNAME 记录,用于识别 worker 节点的每台机器。这些记录必须由集群中的节点解析。 |
在 OpenShift Container Platform 4.4 及更新的版本中,您不需要在 DNS 配置中指定 etcd 主机和 SRV 记录。
您可以使用 dig
命令验证名称和反向名称解析。
1.7.1.1. 平台 "none" 集群的 DNS 配置示例
本节提供了 A 和 PTR 记录配置示例,它满足使用平台 none
选项部署 OpenShift Container Platform 的 DNS 要求。样本不是为选择一个 DNS 解决方案提供建议。
在这个示例中,集群名称为 ocp4
,基域是 example.com
。
平台 "none" 集群的 DNS A 记录配置示例
以下示例是 BIND 区域文件,它显示了使用 platform none
选项在集群中名称解析的 A 记录示例。
例 1.1. DNS 区数据库示例
$TTL 1W @ IN SOA ns1.example.com. root ( 2019070700 ; serial 3H ; refresh (3 hours) 30M ; retry (30 minutes) 2W ; expiry (2 weeks) 1W ) ; minimum (1 week) IN NS ns1.example.com. IN MX 10 smtp.example.com. ; ; ns1.example.com. IN A 192.168.1.5 smtp.example.com. IN A 192.168.1.5 ; helper.example.com. IN A 192.168.1.5 helper.ocp4.example.com. IN A 192.168.1.5 ; api.ocp4.example.com. IN A 192.168.1.5 1 api-int.ocp4.example.com. IN A 192.168.1.5 2 ; *.apps.ocp4.example.com. IN A 192.168.1.5 3 ; master0.ocp4.example.com. IN A 192.168.1.97 4 master1.ocp4.example.com. IN A 192.168.1.98 5 master2.ocp4.example.com. IN A 192.168.1.99 6 ; worker0.ocp4.example.com. IN A 192.168.1.11 7 worker1.ocp4.example.com. IN A 192.168.1.7 8 ; ;EOF
- 1
- 为 Kubernetes API 提供名称解析。记录引用 API 负载均衡器的 IP 地址。
- 2
- 为 Kubernetes API 提供名称解析。记录引用 API 负载均衡器的 IP 地址,用于内部集群通信。
- 3
- 为通配符路由提供名称解析。记录引用应用程序入口负载均衡器的 IP 地址。应用程序入口负载均衡器以运行 Ingress Controller Pod 的机器为目标。默认情况下,Ingress Controller Pod 在计算机器上运行。注意
在这个示例中,将相同的负载均衡器用于 Kubernetes API 和应用入口流量。在生产环境中,您可以单独部署 API 和应用程序入口负载均衡器,以便可以隔离扩展每个负载均衡器基础架构。
- 4 5 6
- 为 control plane 机器提供名称解析。
- 7 8
- 为计算机器提供名称解析。
平台 "none" 集群的 DNS PTR 记录配置示例
下面的 BIND 区文件示例显示集群中使用 platform none
选项反向名称解析的 PTR 记录示例。
例 1.2. 反向记录的 DNS 区数据库示例
$TTL 1W @ IN SOA ns1.example.com. root ( 2019070700 ; serial 3H ; refresh (3 hours) 30M ; retry (30 minutes) 2W ; expiry (2 weeks) 1W ) ; minimum (1 week) IN NS ns1.example.com. ; 5.1.168.192.in-addr.arpa. IN PTR api.ocp4.example.com. 1 5.1.168.192.in-addr.arpa. IN PTR api-int.ocp4.example.com. 2 ; 97.1.168.192.in-addr.arpa. IN PTR master0.ocp4.example.com. 3 98.1.168.192.in-addr.arpa. IN PTR master1.ocp4.example.com. 4 99.1.168.192.in-addr.arpa. IN PTR master2.ocp4.example.com. 5 ; 11.1.168.192.in-addr.arpa. IN PTR worker0.ocp4.example.com. 6 7.1.168.192.in-addr.arpa. IN PTR worker1.ocp4.example.com. 7 ; ;EOF
OpenShift Container Platform 应用程序通配符不需要 PTR 记录。
1.7.2. 平台"none"负载均衡要求
在安装 OpenShift Container Platform 前,您必须置备 API 和应用程序入口负载均衡基础架构。在生产环境中,您可以单独部署 API 和应用程序入口负载均衡器,以便可以隔离扩展每个负载均衡器基础架构。
这些要求不适用于使用 platform none
选项的单节点 OpenShift 集群。
如果要使用 Red Hat Enterprise Linux (RHEL) 实例部署 API 和应用程序入口负载均衡器,您必须单独购买 RHEL 订阅。
负载平衡基础架构必须满足以下要求:
API 负载均衡器 :提供一个通用端点,供用户(包括人工和机器)与平台交互和配置。配置以下条件:
- 仅第 4 层负载均衡.这可称为 Raw TCP、SSL Passthrough 或 SSL 网桥模式。如果使用 SSL Bridge 模式,必须为 API 路由启用 Server Name Indication(SNI)。
- 无状态负载平衡算法。这些选项根据负载均衡器的实施而有所不同。
重要不要为 API 负载均衡器配置会话持久性。
在负载均衡器的前端和后端配置以下端口:
表 1.5. API 负载均衡器 port 后端机器(池成员) internal 外部 描述 6443
控制平面。您必须为 API 服务器健康检查探测配置
/readyz
端点。X
X
Kubernetes API 服务器
22623
控制平面。
X
机器配置服务器
注意负载均衡器必须配置为,从 API 服务器关闭
/readyz
端点到从池中移除 API 服务器实例时最多需要 30 秒。在/readyz
返回错误或健康后的时间范围内,端点必须被删除或添加。每 5 秒或 10 秒探测一次,有两个成功请求处于健康状态,三个成为不健康的请求是经过良好测试的值。应用程序入口负载均衡器 :为应用程序流量从集群外部流提供入口点。OpenShift Container Platform 集群需要正确配置入口路由器。
配置以下条件:
- 仅第 4 层负载均衡.这可称为 Raw TCP、SSL Passthrough 或 SSL 网桥模式。如果使用 SSL Bridge 模式,您必须为入口路由启用 Server Name Indication(SNI)。
- 建议根据可用选项以及平台上托管的应用程序类型,使用基于连接的或基于会话的持久性。
提示如果应用程序入口负载均衡器可以看到客户端的真实 IP 地址,启用基于 IP 的会话持久性可以提高使用端到端 TLS 加密的应用程序的性能。
在负载均衡器的前端和后端配置以下端口:
表 1.6. 应用程序入口负载均衡器 port 后端机器(池成员) internal 外部 描述 443
默认情况下,运行 Ingress Controller Pod、计算或 worker 的机器。
X
X
HTTPS 流量
80
默认情况下,运行 Ingress Controller Pod、计算或 worker 的机器。
X
X
HTTP 流量
注意如果要部署一个带有零计算节点的三节点集群,Ingress Controller Pod 在 control plane 节点上运行。在三节点集群部署中,您必须配置应用程序入口负载均衡器,将 HTTP 和 HTTPS 流量路由到 control plane 节点。
1.7.2.1. 平台 "none" 集群的负载均衡器配置示例
本节提供了一个满足平台 none
选项的集群的负载均衡要求的 API 和应用程序 Ingress 负载均衡器配置示例。示例是 HAProxy 负载均衡器的 /etc/haproxy/haproxy.cfg
配置。这个示例不是为选择一个负载平衡解决方案提供建议。
在这个示例中,将相同的负载均衡器用于 Kubernetes API 和应用入口流量。在生产环境中,您可以单独部署 API 和应用程序入口负载均衡器,以便可以隔离扩展每个负载均衡器基础架构。
如果您使用 HAProxy 作为负载均衡器,并且 SELinux 设置为 enforcing
,您必须通过运行 setsebool -P haproxy_connect_any=1
来确保 HAProxy 服务可以绑定到配置的 TCP 端口。
例 1.3. API 和应用程序入口负载均衡器配置示例
global log 127.0.0.1 local2 pidfile /var/run/haproxy.pid maxconn 4000 daemon defaults mode http log global option dontlognull option http-server-close option redispatch retries 3 timeout http-request 10s timeout queue 1m timeout connect 10s timeout client 1m timeout server 1m timeout http-keep-alive 10s timeout check 10s maxconn 3000 listen api-server-6443 1 bind *:6443 mode tcp server master0 master0.ocp4.example.com:6443 check inter 1s server master1 master1.ocp4.example.com:6443 check inter 1s server master2 master2.ocp4.example.com:6443 check inter 1s listen machine-config-server-22623 2 bind *:22623 mode tcp server master0 master0.ocp4.example.com:22623 check inter 1s server master1 master1.ocp4.example.com:22623 check inter 1s server master2 master2.ocp4.example.com:22623 check inter 1s listen ingress-router-443 3 bind *:443 mode tcp balance source server worker0 worker0.ocp4.example.com:443 check inter 1s server worker1 worker1.ocp4.example.com:443 check inter 1s listen ingress-router-80 4 bind *:80 mode tcp balance source server worker0 worker0.ocp4.example.com:80 check inter 1s server worker1 worker1.ocp4.example.com:80 check inter 1s
- 1
- 端口
6443
处理 Kubernetes API 流量并指向 control plane 机器。 - 2
- 端口
22623
处理机器配置服务器流量并指向 control plane 机器。 - 3
- 端口
443
处理 HTTPS 流量,并指向运行 Ingress Controller pod 的机器。默认情况下,Ingress Controller Pod 在计算机器上运行。 - 4
- 端口
80
处理 HTTP 流量,并指向运行 Ingress Controller pod 的机器。默认情况下,Ingress Controller Pod 在计算机器上运行。注意如果要部署一个带有零计算节点的三节点集群,Ingress Controller Pod 在 control plane 节点上运行。在三节点集群部署中,您必须配置应用程序入口负载均衡器,将 HTTP 和 HTTPS 流量路由到 control plane 节点。
如果您使用 HAProxy 作为负载均衡器,您可以通过在 HAProxy 节点上运行 netstat -nltupe
来检查 haproxy
进程是否在侦听端口 6443
、22623
、443
和 80
。