Red Hat Training

A Red Hat training course is available for OpenShift Container Platform

23.2. 为 GCE 配置 OpenShift Container Platform

您可以通过两种方式为 GCE 配置 OpenShift Container Platform:

23.2.1. 选项 1:使用 Ansible 为 GCP 配置 OpenShift Container Platform

您可以在安装时或安装后修改 Ansible 清单文件,为 Google Compute Platform(GCP)配置 OpenShift Container Platform。

流程

  1. 您至少必须定义 openshift_cloudprovider_kindopenshift_gcp_projectopenshift_gcp_prefix 参数,以及对于 multizone 部署的可选 openshift_gcp_multizone,则为 openshift_gcp_network_name 定义。

    在安装时将以下部分添加到 Ansible 清单文件中,以便为 GCP 配置 OpenShift Container Platform 环境:

    [OSEv3:vars]
    openshift_cloudprovider_kind=gce
    openshift_gcp_project=<projectid> 1
    openshift_gcp_prefix=<uid> 2
    openshift_gcp_multizone=False 3
    openshift_gcp_network_name=<network name> 4
    1
    提供运行现有实例的 GCP 项目 ID。在 Google Cloud Platform 控制台中创建项目时,会生成此 ID。
    2
    提供唯一字符串来标识每个 OpenShift Container Platform 集群。这在 GCP 之间必须是唯一的。
    3
    另外,还可设置为 True 以在 GCP 上触发多 zone 部署。默认设置为 False
    4
    另外,如果没有使用默认网络,则提供网络名称。

    使用 Ansible 安装也会创建并配置以下文件以适合您的 GCP 环境:

    • /etc/origin/cloudprovider/gce.conf
    • /etc/origin/master/master-config.yaml
    • /etc/origin/node/node-config.yaml
  2. 如果您使用 GCP 运行负载均衡器服务,Compute Engine 虚拟机实例需要 ocp 后缀。例如,如果 openshift_gcp_prefix 参数的值设置为 mycluster,则必须标记带有 myclusterocp 的节点。有关如何在 Compute Engine 虚拟机实例中添加网络标签的更多信息,请参阅添加和删除网络标签
  3. 另外,您可以配置多区支持。

    集群安装过程默认配置单区支持,但您可以配置多个区以避免出现单一故障点。

    因为 GCP 磁盘是在区中创建的,在不同的区上的 GCP 中部署 OpenShift Container Platform 可能会导致存储出现问题。如果 OpenShift Container Platform 节点主机在区域 "A" 中停机,并且 pod 移到 zone "B",则持久性存储无法附加到这些 pod,因为磁盘现在位于不同的区。如需更多信息,请参阅 Kubernetes 文档中的多个区限制

    要使用 Ansible 清单文件启用多区支持,请添加以下参数:

    [OSEv3:vars]
    openshift_gcp_multizone=true

    要返回单区支持,将 openshift_gcp_multizone 值设置为 false,然后重新运行 Ansible 清单文件。