kubernetes - 如何在 YAML 文件中指定 GKE 节点池配置,而不是使用 gcloud 容器节点池创建?
问题描述
似乎在 Google Kubernetes Engine 上创建节点池的唯一方法是使用 command gcloud container node-pools create
。我想将所有配置都放在 YAML 文件中。我尝试的是以下内容:
apiVersion: v1
kind: NodeConfig
metadata:
annotations:
cloud.google.com/gke-nodepool: ares-pool
spec:
diskSizeGb: 30
diskType: pd-standard
imageType: COS
machineType: n1-standard-1
metadata:
disable-legacy-endpoints: 'true'
oauthScopes:
- https://www.googleapis.com/auth/devstorage.read_only
- https://www.googleapis.com/auth/logging.write
- https://www.googleapis.com/auth/monitoring
- https://www.googleapis.com/auth/service.management.readonly
- https://www.googleapis.com/auth/servicecontrol
- https://www.googleapis.com/auth/trace.append
serviceAccount: default
但kubectl apply
失败:
error: unable to recognize "ares-pool.yaml": no matches for kind "NodeConfig" in version "v1"
我很惊讶谷歌几乎没有为我的所有搜索产生相关结果。我发现的唯一文档是 Google Cloud 上的文档,在我看来,这很不完整。
解决方案
节点池不是 Kubernetes 对象,它们是 Google Cloud API 的一部分。因此 Kubernetes 不知道它们,并且 kubectl apply 将不起作用。
您真正需要的是一种称为“基础设施即代码”的解决方案——该代码将告诉 GCP 它想要什么样的节点池。
如果您不是严格需要 YAML,您可以查看处理此用例的 Terraform。请参阅:https ://terraform.io/docs/providers/google/r/container_node_pool.html
您还可以查看Google Deployment Manager或Ansible(它具有 GCP 模块,并使用 YAML 语法),它们也可以满足您的需求。
推荐阅读
- centos7 - CentOS 7 sudo >> -E:找不到命令
- javascript - 将用户选择的过滤选项存储到客户端 VIA sessionStorage - 解决方法
- angular - Highcharts Angular 动态更新
- asp.net - ASP.NET 会话变量在用户会话之间泄漏
- sql - 将两个表连接到新表
- git - 如果有人覆盖了我的提交,如何重新提交过去的提交
- javascript - 如何将json数组从字符串转换为对象
- java - 点击后如何按住溢出菜单?
- php - 为什么我的 foreach 没有给我预期的结果?
- java - JAX-RS 请求自定义日期格式