简体   繁体   English

在 GKE 中的现有节点池上添加或编辑标签

[英]Add or edit label on existing node pool in GKE

I created GKE cluster with node pool, but I forgot to label the nodes... In Google Cloud Platform UI I can't edit or add Kubernetes labels for the existing node pool... How can I do it without recreating whole node pool?我创建了带有节点池的 GKE 集群,但我忘记标记节点...在 Google Cloud Platform UI 中,我无法为现有节点池编辑或添加 Kubernetes 标签...如何在不重新创建整个节点池的情况下做到这一点?

标签字段不可更改

It isn't possible to edit the labels without recreating nodes, so GKE does not support updating labels on node pools.不重新创建节点就无法编辑标签,因此 GKE 不支持更新节点池上的标签。

In GKE, the Kubernetes labels are applied to nodes by the kubelet binary which receives them as flags passed in via the node startup script.在 GKE 中,Kubernetes 标签由kubelet二进制文件应用于节点,该二进制文件将它们作为通过节点启动脚本传入的标志接收。 As it is just as disruptive (or more disruptive) to recreate all nodes in a node pool as to create a new node pool, updating the labels isn't a supported operation for updating a node pool.由于重新创建节点池中的所有节点与创建新节点池一样具有破坏性(或更破坏性),因此更新标签不是更新节点池的受支持操作。

You can edit your node configuration, including labels, with kubectl :您可以使用kubectl编辑节点配置,包括标签:

kubectl edit node <your node name>

Use kubectl get node to get a list of your nodes.使用kubectl get node列表。 If you're having trouble connecting to your GKE cluster check out the docs here .如果您在连接到 GKE 集群时遇到问题,请查看此处的文档。

Make a new node pool that is the way you want, and then migrate your workload to it.创建一个您想要的新节点池,然后将您的工作负载迁移到它。 Then destroy the old pool.然后销毁旧池。

Depending on your workload, there could be a "blip" in your service as pods are moved to the new node.根据您的工作负载,当 pod 被移动到新节点时,您的服务中可能会出现“暂时现象”。

I define two node pools: blue and green.我定义了两个节点池:蓝色和绿色。 At any given time only one pool is up.在任何给定时间,只有一个池启动。

If I need to make a change:如果我需要做出改变:

  1. I make sure that automation of the down node pool matches at least the config of the up pool.我确保向下节点池的自动化至少与向上池的配置相匹配。
  2. Then I make the change in the automation that I want in the downed pool.然后我在停机池中进行我想要的自动化更改。
  3. Then I bring up that pool.然后我提出那个游泳池。
  4. I baby-sit the migration of workloads to the new node pool using cordon / drain.我使用警戒线/排水管将工作负载迁移到新节点池。
  5. Then I destroy the old pool.然后我销毁旧池。
  6. Then I make sure that the automation for the old , now down pool, matches the up new pool.然后我确保旧的、现在关闭的池的自动化与新的池匹配。

And I'm ready for my next change.我已经为我的下一次改变做好了准备。

David大卫

kubectl label node <node_id> <label_key>:<label_value>

这将允许您为任何已经运行的节点添加标签。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM