使用 Deployment Manager 部署 Zonal Private GKE 集群时出错
Error when deploying Zonal Private GKE cluster using Deployment Manager
我正在尝试自动部署我的区域私有 GKE 集群。
部署时出现以下错误:
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"}}
根据我的配置文件我不明白:
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)
并基于模板文件
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}
并基于 GCP 文档。
知道我哪里做错了吗?
我无法在 Google 个示例中或其他地方找到此类 Deployment MAnager 的任何示例。
感谢任何反馈!
您只指定了一个区域:CLUSTER_ZONE: europe-west2
。
尝试添加所需的区域,例如CLUSTER_ZONE: europe-west2-b
我正在尝试自动部署我的区域私有 GKE 集群。 部署时出现以下错误:
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"}}
根据我的配置文件我不明白:
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)
并基于模板文件
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}
并基于 GCP 文档。
知道我哪里做错了吗?
我无法在 Google 个示例中或其他地方找到此类 Deployment MAnager 的任何示例。
感谢任何反馈!
您只指定了一个区域:CLUSTER_ZONE: europe-west2
。
尝试添加所需的区域,例如CLUSTER_ZONE: europe-west2-b