Red Hat Training

A Red Hat training course is available for OpenShift Container Platform

5.3.2. 多个使用原生 HA 的 Master

下面描述了使用 原生 HA 方法的三个 master 的示例环境(每个主机上的 etcd 作为静态 pod 运行),一个 HAProxy 负载均衡器,两个用于托管用户应用程序的 节点,具有 用于托管专用基础架构node-role.kubernetes.io/infra=true 标签的两个节点:

主机名安装的组件/角色

master1.example.com

Master(使用原生 HA 进行集群)和 etcd 在每个主机上运行作为静态 pod 的节点

master2.example.com

master3.example.com

lb.example.com

仅平衡 API 主端点的 HAProxy

node1.example.com

Compute 节点

node2.example.com

infra-node1.example.com

专用基础架构节点

infra-node2.example.com

您可以看到以下清单文件的 [masters][etcd][lb][nodes] 部分中出现的这些示例主机:

# 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 availability 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

# host group for masters
[masters]
master1.example.com
master2.example.com
master3.example.com

# host group for etcd
[etcd]
master1.example.com
master2.example.com
master3.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