使用自定义网络进行gke集群部署

时间:2019-09-11 17:29:03

标签: deployment yaml google-kubernetes-engine

我正在尝试创建一个Yaml文件,以在我创建的自定义网络中部署gke集群。我收到错误消息

接收到JSON有效负载。未知名称\“网络\”:找不到字段。“

我为资源尝试了一些名称,但是仍然遇到相同的问题

resources:
- name: myclus
  type: container.v1.cluster
  properties:
    network: projects/project-251012/global/networks/dev-cloud
    zone: "us-east4-a"
    cluster:
      initialClusterVersion: "1.12.9-gke.13"
      currentMasterVersion: "1.12.9-gke.13"
      ## Initial NodePool config.
      nodePools:
      - name: "myclus-pool1"
        initialNodeCount: 3
        version: "1.12.9-gke.13"
        config:
          machineType: "n1-standard-1"
          oauthScopes:
            - https://www.googleapis.com/auth/logging.write
            - https://www.googleapis.com/auth/monitoring
            - https://www.googleapis.com/auth/ndev.clouddns.readwrite
          preemptible: true
## Duplicates node pool config from v1.cluster section, to get it explicitly managed.
- name: myclus-pool1
  type: container.v1.nodePool
  properties:
    zone: us-east4-a
    clusterId: $(ref.myclus.name)
    nodePool:
      name: "myclus-pool1"

我希望它可以将群集节点放置在此网络中。

1 个答案:

答案 0 :(得分:0)

network字段必须是集群规范的一部分。属性的顶级应该只是zoneclusternetwork应该与initialClusterVersion具有相同的缩进。进一步了解container.v1.cluster API reference page

您的清单应该更像:

编辑:关于不推荐使用的字段,API参考文档中存在一些混淆。我提供了适用于新API的YAML,而不是您正在使用的YAML。我已使用基本v1 API的正确语法进行了更新,然后进一步添加了更新的API(当前依赖于gcp-types进行部署。

resources:
- name: myclus
  type: container.v1.cluster
  properties:
    projectId: [project]
    zone: us-central1-f
    cluster:
      name: my-clus
      zone: us-central1-f
      network: [network_name]
      subnetwork: [subnet]   ### leave this field blank if using the default network
      initialClusterVersion: "1.13"
      nodePools:
      - name: my-clus-pool1
        initialNodeCount: 0
        config:
          imageType: cos
- name: my-pool-1
  type: container.v1.nodePool
  properties:
    projectId: [project]
    zone: us-central1-f
    clusterId: $(ref.myclus.name)
    nodePool:
      name: my-clus-pool2
      initialNodeCount: 0
      version: "1.13"
      config:
        imageType: ubuntu

更新的API(提供更多功能并允许您使用更多功能,包括v1beta1 API和Beta功能)看起来像这样:

resources:
- name: myclus
  type: gcp-types/container-v1:projects.locations.clusters
  properties:
    parent: projects/shared-vpc-231717/locations/us-central1-f
    cluster:
      name: my-clus
      zone: us-central1-f
      network: shared-vpc
      subnetwork: local-only   ### leave this field blank if using the default network
      initialClusterVersion: "1.13"
      nodePools:
      - name: my-clus-pool1
        initialNodeCount: 0
        config:
          imageType: cos
- name: my-pool-2
  type: gcp-types/container-v1:projects.locations.clusters.nodePools
  properties:
    parent: projects/shared-vpc-231717/locations/us-central1-f/clusters/$(ref.myclus.name)
    nodePool:
      name: my-clus-separate-pool
      initialNodeCount: 0
      version: "1.13"
      config:
        imageType: ubuntu

另一个注意事项,您可能想要修改范围,当前范围不允许您从gcr.io中提取图像,某些系统吊舱可能无法正常旋转,如果您使用的是Google的存储库,则无法拉那些图像。

最后,您不想在集群规范中和在单独的集群中重复节点池资源。而是使用基本(默认)节点池创建群集,对于所有其他节点池,将它们创建为单独的资源来管理它们而不通过群集。除了调整大小外,您只能在节点池上执行很少的更新

相关问题