Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubectl delete but ignore ones with error

I have a list of namespaces and i want to delete them but some of them are giving error and i want to skip that ones and continue other deletions. How can i do that?

kubectl delete services,deployments -n ${namespace} --all  --grace-period=10
like image 764
meursault Avatar asked Aug 18 '20 11:08

meursault


People also ask

How do I get rid of error pods?

For deleting all failed pods in all namespaces you can use this command: kubectl delete pods --field-selector status. phase=Failed -A . But, for using this command, you need to configure the restartPolicy as the pod will restart again and again. And that is it!

What does kubectl delete do?

You can delete a StatefulSet in the same way you delete other resources in Kubernetes: use the kubectl delete command, and specify the StatefulSet either by file or by name. You may need to delete the associated headless service separately after the StatefulSet itself is deleted.

What happens when kubectl Delete pod?

If you manually deploy a single pod and then delete it, your service will go down and won't come back up. If a service is running through a replica set but with only one pod, the service will become unavailable after deleting the pod.


1 Answers

You can try using --ignore-not-found=true flag in command

kubectl delete deployments --ignore-not-found=true -n ${namespace} --all  --grace-period=10
like image 94
Dashrath Mundkar Avatar answered Oct 21 '22 09:10

Dashrath Mundkar