从 Cloud Deployment Manager 创建 GKE

GKE Creation from Cloud Deployment Manager

Waiting for create [operation-1544424409972-57ca55456bd22-84bb0f13-64975fdc]...failed.
ERROR: (gcloud.deployment-manager.deployments.create) Error in Operation [operation-1544424409972-57ca55456bd22-84bb0f13-64975fdc]: errors:
- code: CONDITION_NOT_MET
  location: /deployments/infrastructure/resources/practice-gke-clusters->$.properties->$.cluster.name
  message: |-
    InputMapping for field [cluster.name] for method [create] could not be set from input, mapping was: [$.ifNull($.resource.properties.cluster.name, $.resource.name)
    ], and evaluation context was:
    {
      "deployment" : {
        "id" : 4291795636642362677,
        "name" : "infrastructure"
      },
      "intent" : "CREATE",
      "matches" : [ ],
      "project" : "resources-practice",
      "requestId" : "",
      "resource" : {
        "name" : "practice-gke-clusters",
        "properties" : {
          "initialNodeCount" : 1,
          "location" : "asia-east2-a",
          "loggingService" : "logging.googleapis.com",
          "monitoringService" : "monitoring.googleapis.com",
          "network" : "$(ref.practice-gke-network.selfLink)",
          "subnetwork" : "$(ref.practice-gke-network-subnet-1.selfLink)"
        },
        "self" : { }
      }
    }

当我尝试使用下面的 jinja 模板从部署管理器创建 GKE 时,我总是遇到这种情况

resources:
- name: practice-gke-clusters
  type: container.v1.cluster
  properties: 
    network: $(ref.practice-gke-network.selfLink)
    subnetwork: $(ref.practice-gke-network-subnet-1.selfLink)
    initialNodeCount: 1
    loggingService: logging.googleapis.com
    monitoringService: monitoring.googleapis.com
    location: asia-east2-a

你还缺少:

properties:
    cluster:
        name: practice-gke-clusters
        initialNodeCount: 3
        nodeConfig:
            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

根据需要修改 initialNodeCountoauthScopes