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 年前檢視次數 10899 次
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.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南