将GKE测试版功能与GCP Deployment Manager一起使用

时间:2018-04-30 02:44:18

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

我尝试使用GCP部署管理器创建GKE REGION群集(测试版功能)。 但我得到了错误。有没有办法将GKE beta功能(包括区域群集)与Deployment Manager一起使用?

ERROR: (gcloud.beta.deployment-manager.deployments.create) Error in             
Operation [operation-1525054837836-56b077fdf48e0-a571296c-604523fb]: 
errors:
- code: RESOURCE_ERROR
  location: /deployments/test-cluster1/resources/source-cluster
  message: '{"ResourceType":"container.v1.cluster","ResourceErrorCode":"400","ResourceErrorMessage":{"code":400,"message":"v1 API cannot be used to access GKE regional clusters. See https://cloud.google.com/kubernetes-engine/docs/reference/api-organization#beta for more information.","status":"INVALID_ARGUMENT","statusMessage":"Bad Request","requestPath":"https://container.googleapis.com/v1/projects/project_id/zones/us-central1/clusters","httpMethod":"POST"}}'

在错误消息中,链接gcp help。

https://cloud.google.com/kubernetes-engine/docs/reference/api-organization#beta

按照说明进行配置,但仍然出现错误。

我的部署经理yaml文件看起来像,

resources:
- name: source-cluster
type: container.v1.cluster
properties:
  zone: us-central1
  cluster:
    name: source
    initialNodeCount: 3

然而,区域集群是完全有效的。所以我认为它与部署管理器命令中容器v1beta api的使用有关。

resources:
- name: source-cluster
type: container.v1.cluster
properties:
  zone: us-central1-b
  cluster:
    name: source
    initialNodeCount: 3

感谢。

1 个答案:

答案 0 :(得分:1)

您收到的错误消息似乎与您尝试使用测试版功能但您正在使用API​​ v1(即container.v1.cluster)指定Deployment Manager资源这一事实有关。这意味着您尝试创建的beta资源与指定资源之间存在差异。

我已经了解了这一点,并发现通过Deployment Manager添加区域群集的功能是Google Cloud Platform的最新成员,详见本public feature request中最近才实施的内容。

似乎您需要将API类型指定为'gcp-types / container-v1beta1:projects.locations.clusters'才能使其工作,而不是在YAML中使用'zone'或'region'键,您将改为使用包含位置的父属性。

所以你的YAML看起来像这样(用你自己的替换PROJECT_ID)。

resources:
- type:  gcp-types/container-v1beta1:projects.locations.clusters
  name: source-cluster
  properties:
   parent: projects/PROJECT_ID/locations/us-central1
   cluster:
     name: source
     initialNodeCount: 3