如何使用部署经理在GKE中建立区域集群?

时间:2018-12-12 06:42:10

标签: google-cloud-platform google-kubernetes-engine google-deployment-manager

在尝试创建时,“区域”是必填字段,但在文档中指出“已弃用”。这有点误导。然后,每次我包含“区域”。这是紧随其后的;假设我输入“ asia-east2-a”,它将是主节点位于asia-east2-a的区域。

下面是我的Jinja模板

resources:
- name: practice-gke-clusters
  type: container.v1.cluster
  properties:
    zone: asia-east2-a
    cluster:
      name: practice-gke-clusters
      location: asia-east2
      network: $(ref.practice-gke-network.selfLink)
      subnetwork: $(ref.practice-gke-network-subnet-1.selfLink)
      nodePools:
        - name: default-pool
          config:
            machineType: n1-standard-1
            diskSizeGb: 10
            diskType: pd-ssd
            preemptible: True
            oauthScopes:
              - https://www.googleapis.com/auth/compute
              - https://www.googleapis.com/auth/devstorage.read_only
              - https://www.googleapis.com/auth/logging.write
              - https://www.googleapis.com/auth/monitoring
          initialNodeCount: 1
          autoscaling:
            enabled: True
            minNodeCount: 1
            maxNodeCount: 100
          management:
            autoUpgrade: False
            autoRepair: True
      loggingService: logging.googleapis.com
      monitoringService: monitoring.googleapis.com

1 个答案:

答案 0 :(得分:0)

当前,v1 API不支持创建区域集群。但是,您可以使用支持此feature的v1beta1 API并使用以下资源类型:

类型:gcp-types / container-v1beta1:projects.locations.clusters

您可以使用包含位置的父级属性,而不是在YAML中使用“ zone”或“ region”键。

因此您的YAML看起来像这样(用您自己的PROJECT_ID和REGION代替)。

resources:
- type:  gcp-types/container-v1beta1:projects.locations.clusters  # previously container.v1.clusters
  name: source-cluster
  properties:
   parent: projects/PROJECT_ID/locations/REGION
   cluster:
     name: source
     initialNodeCount: 3