How to gracefully remove a node from Kubernetes?

List the nodes and get the <node-name> you want to drain or (remove from cluster)

kubectl get nodes

1) First drain the node

kubectl drain <node-name>

You might have to ignore daemonsets and local-data in the machine

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

2) Edit instance group for nodes (Only if you are using kops)

kops edit ig nodes

Set the MIN and MAX size to whatever it is -1
Just save the file (nothing extra to be done)

You still might see some pods in the drained node that are related to daemonsets like networking plugin, fluentd for logs, kubedns/coredns etc

3) Finally delete the node

kubectl delete node <node-name>

4) Commit the state for KOPS in s3: (Only if you are using kops)

kops update cluster --yes

OR (if you are using kubeadm)

If you are using kubeadm and would like to reset the machine to a state which was there before running kubeadm join then run

kubeadm reset

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)