Removing a Node - gpillon/k4all GitHub Wiki
When you need to remove a node from your Kubernetes cluster, follow these steps to ensure it is properly disconnected and removed from both Kubernetes and the etcd datastore.
First, you must drain the node to ensure that all the running pods are safely evicted. This can be done using the following kubectl
command:
kubectl drain <node-name> --ignore-daemonsets --delete-emptydir-data
Replace with the actual name of the node you wish to remove.
After the node has been drained, you can remove it from the cluster by running:
kubectl delete node <node-name>
kubectl get pods -n kube-system | grep etcd
and write down the etcd-pod-name (eg. "etcd-kube-control-a1010")
kubectl exec <etcd-pod-name> -n kube-system -- etcdctl --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/peer.crt --key /etc/kubernetes/pki/etcd/peer.key member list
take note on the etcd-member-id of the node you removed (eg. "3cce9d6104afe4be")
kubectl exe <etcd-pod-name> -n kube-system -- etcdctl --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/peer.crt --key /etc/kubernetes/pki/etcd/peer.key member remove <etcd-member-id>