Red Hat Training
A Red Hat training course is available for OpenShift Container Platform
5.3. 多个主页示例
您可以配置具有多个 master、多个 etcd 主机和多个节点的环境。为高可用性(HA)配置多个 master 可确保集群没有单点故障。
在安装后从单一 master 集群移动到多个 master 集群不被支持。
在配置多个 master 时,集群安装过程支持原生
的高可用性(HA)方法。此方法利用了 OpenShift Container Platform 中内置的原生 HA master 功能,并可与任何负载均衡解决方案结合使用。
如果在清单文件的 [lb] 部分中定义了主机,Ansible 会自动安装并配置 HAProxy 作为 master 的负载均衡解决方案。如果没有定义主机,则假设您已预先配置了您选择的外部负载均衡解决方案,以在所有 master 主机上平衡 master API(端口 8443)。
此 HAProxy 负载均衡器旨在演示 API 服务器的 HA 模式,不建议在生产环境中使用。如果您要部署到云供应商中,红帽建议部署基于云原生 TCP 的负载均衡器,或者采取其他步骤来提供高度可用的负载均衡器。
HAProxy 负载均衡器仅用于对 API 服务器的流量进行负载平衡,且不会对任何用户应用程序流量进行负载平衡。
对于外部负载平衡解决方案,您必须有:
- 为 SSL passthrough 配置预创建的负载均衡器虚拟 IP(VIP)。
-
由
openshift_master_api_port
值 (默认为 8443)指定的端口上的 VIP 监听,并从那个端口上返回到所有 master 主机的代理。 在 DNS 中注册的 VIP 的域名。
-
域名将成为 OpenShift Container Platform 安装程序中的
openshift_master_cluster_public_hostname
和openshift_master_cluster_hostname
的值。
-
域名将成为 OpenShift Container Platform 安装程序中的
如需更多信息,请参阅 Github 中的 External Load Balancer 集成示例。有关高可用性 master 架构的更多信息,请参阅 Kubernetes Infrastructure。
集群安装过程目前不支持主动被动(active-passibe)设置中的多个 HAProxy 负载均衡器。有关安装后的详情,请查看 Load Balancer 管理文档。
要配置多个 master,请参阅使用 多个 etcd 的多 Master
5.3.1. 多个使用原生 HA 的、带有外部集群 etcd 的 Master。
下面描述了使用 原生
HA 方法的三个 master 的示例环境:一个 HAProxy 负载均衡器,三个 etcd 主机,两个用于托管用户应用程序的节点,具有 用于托管专用基础架构 的 node-role.kubernetes.io/infra=true
标签的两个节点:
主机名 | 安装的组件/角色 |
---|---|
master1.example.com | Master(使用原生 HA 进行集群)和节点 |
master2.example.com | |
master3.example.com | |
lb.example.com | 仅平衡 API 主端点的 HAProxy |
etcd1.example.com | etcd |
etcd2.example.com | |
etcd3.example.com | |
node1.example.com | Compute 节点 |
node2.example.com | |
infra-node1.example.com | 专用基础架构节点 |
infra-node2.example.com |
您可以看到以下清单文件的 [masters]、[etcd]、[lb] 和 [nodes] 部分中出现的这些示例主机:
使用 HAProxy 清单文件的多个 Master
# Create an OSEv3 group that contains the master, nodes, etcd, and lb groups. # The lb group lets Ansible configure HAProxy as the load balancing solution. # Comment lb out if your load balancer is pre-configured. [OSEv3:children] masters nodes etcd lb # Set variables common for all OSEv3 hosts [OSEv3:vars] ansible_ssh_user=root openshift_deployment_type=openshift-enterprise # uncomment the following to enable htpasswd authentication; defaults to DenyAllPasswordIdentityProvider #openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider'}] # Native high availbility cluster method with optional load balancer. # If no lb group is defined installer assumes that a load balancer has # been preconfigured. For installation the value of # openshift_master_cluster_hostname must resolve to the load balancer # or to one or all of the masters defined in the inventory if no load # balancer is present. openshift_master_cluster_method=native openshift_master_cluster_hostname=openshift-internal.example.com openshift_master_cluster_public_hostname=openshift-cluster.example.com # apply updated node defaults openshift_node_groups=[{'name': 'node-config-all-in-one', 'labels': ['node-role.kubernetes.io/master=true', 'node-role.kubernetes.io/infra=true', 'node-role.kubernetes.io/compute=true'], 'edits': [{ 'key': 'kubeletArguments.pods-per-core','value': ['20']}]}] # host group for masters [masters] master1.example.com master2.example.com master3.example.com # host group for etcd [etcd] etcd1.example.com etcd2.example.com etcd3.example.com # Specify load balancer host [lb] lb.example.com # host group for nodes, includes region info [nodes] master[1:3].example.com openshift_node_group_name='node-config-master' node1.example.com openshift_node_group_name='node-config-compute' node2.example.com openshift_node_group_name='node-config-compute' infra-node1.example.com openshift_node_group_name='node-config-infra' infra-node2.example.com openshift_node_group_name='node-config-infra'
请参阅 配置节点主机标签,以确保您了解从 OpenShift Container Platform 3.9 开始的默认节点选择器要求和节点标签注意事项。
要使用本例,修改该文件以符合您的环境和规格,并将它保存为 /etc/ansible/hosts。