2

我正在尝试使用 GCP 部署管理器创建 GKE REGION 集群(测试版功能)。但我得到了错误。有没有办法通过部署管理器使用 GKE 测试版功能(包括区域集群)?

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 帮助的链接。

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

谢谢。

4

1 回答 1

1

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

我对此进行了研究,发现通过部署管理器添加区域集群的功能是谷歌云平台的最新功能,如最近才实施的这个公共功能请求中所述。

看来您需要将 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
于 2018-04-30T12:29:49.630 回答