设置 Google Compute Engine 云提供商

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

详情请参见 GCE 云提供商的官方 Kubernetes 文档

设置 Google Compute Engine 云提供商 - 图1先决条件:

GCE 上的 Identity ServiceAccount 和 API 访问需要Computer Admin权限。

如果你使用 Calico:

  1. 点击 ☰ > 集群管理

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

    1. rancher_kubernetes_engine_config:
    2. cloud_provider:
    3. name: gce
    4. customCloudProvider: |-
    5. [Global]
    6. project-id=<your project ID, optional>
    7. network-name=<your network, optional if using default network>
    8. subnetwork-name=<your subnetwork of the above network, optional if using default network>
    9. node-instance-prefix=<your instance group name/your instance name specific prefix, required>
    10. node-tags=<your network tags, must patch one or some tags, required>
    11. network:
    12. options:
    13. calico_cloud_provider: "gce"
    14. plugin: "calico"

如果你使用 Canal 或 Flannel:

  1. 点击 ☰ > 集群管理

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

    1. rancher_kubernetes_engine_config:
    2. cloud_provider:
    3. name: gce
    4. customCloudProvider: |-
    5. [Global]
    6. project-id=<your project ID, optional>
    7. network-name=<your network, optional if using default network>
    8. subnetwork-name=<your subnetwork of the above network, optional if using default network>
    9. node-instance-prefix=<your instance group name/your instance name specific prefix, required>
    10. node-tags=<your network tags, must patch one or some tags, required>
    11. services:
    12. kube_controller:
    13. extra_args:
    14. configure-cloud-routes: true # we need to allow the cloud provider configure the routes for the hosts