using kubectl delete command to remove core-dns pod blocked / No activity

2/12/2020

I found my coredns pod throw error: Readiness probe failed: Get http://172.30.224.7:8080/health: net/http: request canceled (Client.Timeout exceeded while awaiting headers) . I am delete pod using this command:

kubectl delete pod coredns-89764d78c-mbcbz -n kube-system

but the command keep waiting and nothing response,how to know the progress of deleting? this is output:

[root@ops001 ~]# kubectl delete pod coredns-89764d78c-mbcbz -n kube-system
pod "coredns-89764d78c-mbcbz" deleted

and the terminal hangs or blocked,when I use browser UI with using kubernetes dashboard the pod exits.how to force delete it? or fix it the right way?

enter image description here

-- Dolphin
kubernetes

2 Answers

2/12/2020

Answering another part of your question:

but the command keep waiting and nothing response,how to know the progress of deleting? this is output:

[root@ops001 ~]# kubectl delete pod coredns-89764d78c-mbcbz -n kube-system
pod "coredns-89764d78c-mbcbz" deleted

and the terminal blocked...

When you're deleting a Pod and you want to see what's going on under the hood, you can additionally provide -v flag and specify the desired verbosity level e.g.:

kubectl delete pod coredns-89764d78c-mbcbz -n kube-system -v 8

If there is some issue with the deletion of specific Pod, it should tell you the details.

I totally agree with @P Ekambaram's comment:

if coredns is not started. you need to check logs and find out why it is not getting started – P Ekambaram

You can always delete the whole coredns Deployment and re-deploy it again but generally you shouldn't do that. Looking at Pod logs:

kubectl logs coredns-89764d78c-mbcbz -n kube-system

should also tell you some details explaining why it doesn't work properly. I would say that deleting the whole coredns Deployment is a last resort command.

-- mario
Source: StackOverflow

2/12/2020

You are deleting a pod which is monitored by deployment controller. That's why when you delete one of the pods, the controller create another to make sure the number of pods equal to the replica count. If you really want to delete the coredns[not recommended], delete the deployment instead of the pods.

$ kubectl delete deployment coredns -n kube-system
-- Kamol Hasan
Source: StackOverflow