Error when deploying Zonal Private GKE cluster using Deployment Manager

9/28/2018

I am trying to automate the deployment of my Zonal Private GKE Cluster. I have the following error when deploying:

ci-qa: {"ResourceType":"gcp-types/container-v1beta1:projects.zones.clusters","ResourceErrorCode":"400","ResourceErrorMessage":{"code":400,"message":"'zone' field cannot be used to access GKE regional clusters. Use 'name' or 'parent' fields instead.","status":"INVALID_ARGUMENT","statusMessage":"Bad Request","requestPath":"https://container.googleapis.com/v1beta1/projects/YYZ/zones/europe-west2/clusters","httpMethod":"POST"}}

Which I don't understand based on my config file:

imports:
- path: python/kubernetes_engine_private_zonal_cluster.py
  name: kubernetes_engine_private_zonal_cluster.py
- path: python/kubernetes_engine_apis.py
  name: kubernetes_engine_apis.py

resources:
- name: cluster
  type: kubernetes_engine_private_zonal_cluster.py
  properties:
    CLUSTER_NAME: ci-qa
    CLUSTER_ZONE: europe-west2
    NUM_NODES: 3
    CLUSTER_SERVICESIPV4CIDRBLOCK: 172.17.0.0/16
    CLUSTER_NETWORK: vpc1-priv
    CLUSTER_CLUSTERIPV4CIDR: 172.16.0.0/16
    CLUSTER_SUBNETWORK: vpc1-priv-euwe1-1
    CLUSTER_MACHINE_TYPE: n1-standard-4
    CLUSTER_VERSION: 1.10.7-gke.1

- name: types
  type: kubernetes_engine_apis.py
  properties:
    endpoint: $(ref.cluster.endpoint)

And based on the template file

def GenerateConfig(context):
'""Generate YAML resource configuration.""'

cluster_name = context.properties['CLUSTER_NAME']
cluster_zone = context.properties['CLUSTER_ZONE']
number_of_nodes = context.properties['NUM_NODES']
cluster_servicesIpv4CidrBlock = context.properties['CLUSTER_SERVICESIPV4CIDRBLOCK']
cluster_network = context.properties['CLUSTER_NETWORK']
cluster_clusterIpv4Cidr = context.properties['CLUSTER_CLUSTERIPV4CIDR']
cluster_subnetwork = context.properties['CLUSTER_SUBNETWORK']
cluster_machine_type = context.properties['CLUSTER_MACHINE_TYPE']
cluster_version = context.properties['CLUSTER_VERSION']

resources = []
outputs = []

resources.append({
    'name': cluster_name,
    'type': 'gcp-types/container-v1beta1:projects.zones.clusters',
    'properties': {
        'zone': cluster_zone,
        'cluster': {
            'name': cluster_name,
            'description': 'Private Cluster',
            'initialNodeCount': number_of_nodes,
            'initialClusterVersion': cluster_version,
            'privateCluster': True,
            'loggingService': 'logging.googleapis.com',
            'monitoringService': 'monitoring.googleapis.com',
            'network': cluster_network,
            'clusterIpv4Cidr': cluster_clusterIpv4Cidr,
            'subnetwork': cluster_subnetwork,
            'nodeConfig': {
                'oauthScopes': [
                    'https://www.googleapis.com/auth/' + scope
                    for scope in [
                        'compute',
                        'devstorage.read_only',
                        'logging.write',
                        'monitoring'
                    ]
                ],
                'machineType': cluster_machine_type,
                'imageType': 'COS',
                'preemptible': True
            },
            # 'nodePools': {
            #     'name': 'test',
            #     'initialNodeCount': number_of_nodes,
            #     'oauthScopes': [
            #         'https://www.googleapis.com/auth/' + scope
            #         for scope in [
            #             'compute',
            #             'devstorage.read_only',
            #             'logging.write',
            #             'monitoring'
            #         ]
            #     ],
            #     'machineType': cluster_machine_type,
            #     'imageType': 'COS'
            # },
            'ipAllocationPolicy': {
                'useIpAliases': True,
                'createSubnetwork': False,
                'servicesIpv4CidrBlock': cluster_servicesIpv4CidrBlock
            }
        }
    }
})
outputs.append({
    'name': 'endpoint',
    'value': '$(ref.' + cluster_name + '.endpoint)'
})
return {'resources': resources, 'outputs': outputs}

and based on the GCP documentation.

Any idea where I did a mistake?

I cannnot find any example of such Deployment MAnager either in Google examples, either somewhere else.

Thanks for any feedback!

-- Indigo Ping
google-deployment-manager
google-kubernetes-engine
kubernetes

1 Answer

9/28/2018

You are only specifying a region: CLUSTER_ZONE: europe-west2.

Try adding the desired zone, e.g. CLUSTER_ZONE: europe-west2-b

-- Jukka
Source: StackOverflow