本文档采用自动化机器翻译技术翻译。 尽管我们力求提供准确的译文,但不对翻译内容的完整性、准确性或可靠性作出任何保证。 若出现任何内容不一致情况,请以原始 英文 版本为准,且原始英文版本为权威文本。

设置 Google Compute Engine 云提供商

在本节中,您将学习如何为 Rancher 中的自定义集群启用 Google Compute Engine (GCE) 云提供商。自定义集群是指 Rancher 在现有节点上安装 Kubernetes 的集群。

GCE 云提供商的官方 Kubernetes 文档在 这里。

先决条件:

在 GCE 上,Identity and API 的服务账户需要 Computer Admin 权限。

如果您使用 Calico,

  1. 单击 ☰ > 集群管理

  2. 集群 页面,进入自定义集群并点击 _*⋮ > 编辑 YAML。_输入以下配置:

     rancher_kubernetes_engine_config:
       cloud_provider:
         name: gce
         customCloudProvider: |-
           [Global]
           project-id=<your project ID, optional>
           network-name=<your network, optional if using default network>
           subnetwork-name=<your subnetwork of the above network, optional if using default network>
           node-instance-prefix=<your instance group name/your instance name specific prefix, required>
           node-tags=<your network tags, must patch one or some tags, required>
       network:
         options:
           calico_cloud_provider: "gce"
         plugin: "calico"

如果您使用 Canal 或 Flannel,

  1. 单击 ☰ > 集群管理

  2. 集群 页面,进入自定义集群并点击 _*⋮ > 编辑 YAML。_输入以下配置:

     rancher_kubernetes_engine_config:
       cloud_provider:
         name: gce
         customCloudProvider: |-
           [Global]
           project-id=<your project ID, optional>
           network-name=<your network, optional if using default network>
           subnetwork-name=<your subnetwork of the above network, optional if using default network>
           node-instance-prefix=<your instance group name/your instance name specific prefix, required>
           node-tags=<your network tags, must patch one or some tags, required>
       services:
         kube_controller:
           extra_args:
             configure-cloud-routes: true # we need to allow the cloud provider configure the routes for the hosts