Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to forcefully delete a daemonset or a pod in kubernetes cluster

Tags:

kubernetes

I have setup a kubernetes cluster which is working fine. I created deployment with type as daemonset which then created few pods and it worked fine. I made few changes so I deleted the daemonset using:

kubectl delete daemonset <name> --namespace=clustech

While few pods were getting deleted, few of the machine went offline and thus the pods running on them went on to say unknown status. I need to remove those pods or completely remove that previous daemonset but unable to do. I am using below commands to delete pods:

kubectl delete pod PODNAME --grace-period=0 --force

But this shows below error:

warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
Error from server (NotFound): pods "deployment-6sj54" not found

How can I delete the pods.?

like image 646
S Andrew Avatar asked Feb 03 '23 23:02

S Andrew


2 Answers

Re-run the second command with namespace parameter will do your job.

--grace-period=0 --force is the right command to delete such pods.

like image 115
Kun Li Avatar answered Feb 06 '23 13:02

Kun Li


You can delete a daemonset.apps using this command:

kubectl delete --all daemonset.apps -n <namespace>

like image 31
Rod Talingting Avatar answered Feb 06 '23 12:02

Rod Talingting