How to remove a specific node from EKS node group (none managed eksctl)

0

I have a small EKS cluster created by eksctl. It consists of 2 node groups (none managed).

The first group runs the management app and currently consists of a single node, the second group runs the "worker" pods and has 3 nodes.

I have received an event notification that the EC2 machine that is the single node in the management nodegroup is scheduled to be shutdown due to maintenance. My plan is to scale the group to 2 nodes and then use kubectl drain to evict the running application so it will move to the new node. All good so far.

My question is how to then remove the original node before EC2 shuts it down (and presumably starts a replacement)? Is there a way to specify a specific node when scaling the group back down to a single node with eksctl? Or will it be smart enough to pick the node that is already drained/cordoned?

已提问 2 年前10900 查看次数
1 回答
1
已接受的回答

I understand one of the EKS node is scheduled for the maintenance. Currently you have second group that runs the "worker" pods and has 3 nodes. You want to scale in the group to 2 nodes and want the node scheduled for the maintenance should are removed as part of scale in. You have workload already transferred to other 2 node at moment.

Below is list of steps I have tested in my test environment to achieve this.

You might already be aware you have autoscaling group for the group and it takes care of launching/termination of node and keep the node count as per you autoscaling desired capacity.

  • Drain on EKS:

$ kubectl get nodes

$ kubectl cordon <node name>

$ kubectl drain <node name> --ignore-daemonsets

To terminate the instance and also decrements the size of the Auto Scaling group.

$ aws autoscaling terminate-instance-in-auto-scaling-group --instance-id <INSTANCE_ID> --should-decrement-desired-capacity --region <REGION>

Refer: https://docs.aws.amazon.com/cli/latest/reference/autoscaling/terminate-instance-in-auto-scaling-group.html

AWS
支持工程师
Sishu_R
已回答 2 年前
profile pictureAWS
专家
Toni_S
已审核 2 年前
  • Thanks, If you can give the folk at weave a poke, this would be really nice to wrap up in the eksctl command.

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则