调整容器引擎集群上的实例类型

Resize instance types on Container Engine cluster

我们的一些容器 运行 内存高于我们容器引擎集群中当前部署的实例类型。在创建容器引擎集群后,是否有推荐的做法为更大的实例重建容器引擎模板?

例如,对于 运行具有 8GB 以上 RAM 的宁容器,从 GCE 实例 n1-standard-2 到 n1-highmem-8?

Container Engine 目前没有 API 来执行此操作,但由于它使用看起来像 "gke--" 的 Compute Engine instance group for the nodes in your cluster, you can actually update it without needing GKE's help. In the Developers Console, copy the instance template 并修改其中的机器类型,然后编辑类似命名的实例组使用新模板。您可以分别在 Compute > Compute Engine > Instance templatesCompute > Compute Engine > Instance groups 下找到这些选项。

另一种方法是:

(1) 为具有垂直扩展机器类型的 GKE 集群创建一个新的 node-pool ...

$ gcloud container node-pools create pool-n1std2 --zone europe-west1-d --cluster prod-cluster-1 --machine-type  n1-standard-2  --image-type gci --disk-size=250 --num-nodes 3

(2) 然后,将工作负载迁移出旧节点 ...

$ kubectl drain gke-prod-cluster-1-default-pool-f1eabad5-9ml5 --delete-local-data --force

(3) 最后,删除旧的 node-pool

$ gcloud container node-pools delete default-pool --cluster=prod-cluster-1

备注:

  • 警告:第 2 步删除节点本地卷,如 emptyDir!!!
  • 需要为池中的每个节点重复步骤 2
  • 可以配置适当的 nodeSelector 以将 pods 调度到新池中,而不是耗尽节点。要匹配的标签将是 cloud.google.com/gke-nodepool: pool-n1std2

go from GCE instances n1-standard-2 to n1-highmem-8 for running containers with above 8GB RAM?

Kubernetes 1.12(2018 年 9 月)应该提供一种官方方式来管理您现有的资源 kubernetes issue 21 "Vertical Scaling of Pods"(或“VPA”:垂直 Pod 自动缩放器").

作为announced on the blog:

Vertical Scaling of Pods is now in beta, which makes it possible to vary the resource limits on a pod over its lifetime. In particular, this is valuable for pets (i.e., pods that are very costly to destroy and re-create).

Warning:

这是在 1.12 左右登陆,但它是一个独立插件的发布。它不包含在 1.12 Kubernetes 版本中。
Sig-Architecture 在本周期开始时决定将 VPA API 保留为 CRD,因此不将其绑定到任何特定的 K8S 版本。

查看更多内容:

BanzaiCloud 的最后一篇文章有​​点过时(一些链接不再有效),但它仍然说明了如何管理 pod 资源。

有官方的 GKE 教程:

将工作负载迁移到不同的机器类型
"本教程演示了如何将 GKE 集群上的工作负载运行迁移到同一集群中的一组新节点,而不会导致您的应用程序停机。如果您想将工作负载迁移到具有不同机器类型的节点,这种迁移会很有用。"

https://cloud.google.com/kubernetes-engine/docs/tutorials/migrating-node-pool