如何优雅地排空 EKS 中的节点? [英] How to gracefully drain a node in EKS?

查看:23
本文介绍了如何优雅地排空 EKS 中的节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时我们需要排空 Kubernetes 中的节点.当我手动设置 k8s 集群时,我可以排空特定节点,然后终止该机器.在 EKS 中,节点在 Auto Scaling 组中,这意味着我无法终止特定实例(节点).如果我手动终止一个实例,另一个实例(节点)将自动添加到 eks 集群中.

Sometimes we need to drain nodes in Kubernetes. When I manually set up a k8s cluster, I can drain the specific node then terminate that machine. While in EKS, nodes are under auto scaling group, which means I can't terminate a specific instance(node). If I manually terminate a instance, another instance(node) will be automatically added into eks cluster.

那么是否有任何建议的方法可以在 EKS 中排空节点?

So is there any suggested method to drain a node in EKS?

推荐答案

这些步骤应该有效:

1.) kubectl 获取节点

1.) kubectl get nodes

2.) kubectl 警戒线

2.) kubectl cordon <node name>

3.) kubectl drain --ignore-daemonsets

3.) kubectl drain <node name> --ignore-daemonsets

4.) aws autoscaling terminate-instance-in-auto-scaling-group --instance-id --should-decrement-desired-capacity

4.) aws autoscaling terminate-instance-in-auto-scaling-group --instance-id <instance-id> --should-decrement-desired-capacity

对于第 3 步,您可能需要考虑使用它:

For step 3, you might need to consider using this instead:

kubectl drain --ignore-daemonsets --delete-local-data

kubectl drain <node name> --ignore-daemonsets --delete-local-data

对于 AWS 自动缩放组,如果您的节点跨越多个区域,请考虑删除每个区域中的节点,而不是单个区域中的所有节点.

For AWS autoscaling group, if you have nodes span out to multiple zones, consider delete nodes in each zones instead of all nodes from a single zone.

执行上述命令后,检查自动缩放组的所需数量.它应该会自动减少.如果您正在使用 terraform 或其他自动化框架,请不要忘记在您的基础设施脚本中更新您的自动缩放组配置.

After the execution of the above commands, check the autoscaling group's desired number. It should decrease automatically. If you are using terraform or other automation framework, don't forget to update your autoscaling group config in your infrastructure script.

这篇关于如何优雅地排空 EKS 中的节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆