How to remove the pods of a removed nodes

8/19/2020

I have removed and delete a node from k8s cluster using the following commands:

kubectl drain worker1 --ignore-daemonsets

kubectl delete worker1

After that, I saw the kube-proxy and the weave daemonset(both for worker1) still existed (it is expected since I ignored the daemonset)even the nodes is drained and deleted.

How can I remove these pods if the node(worker1) is drained and deleted.

Thank you

-- sam ngai
kubectl
kubernetes

1 Answer

8/19/2020

Find out the name of the pod which is scheduled on that deleted node and delete the pod using kubectl delete pods <pod_name> --grace-period=0 --force -n <namespace>

Use below command to display more details about pod including the node on which the pod is scheduled

kubectl get pods -n <namespace> -o wide

You could also use kubeadm reset on that node. Please note this will uninstall and remove all Kubernetes related software from that node.

-- Arghya Sadhu
Source: StackOverflow