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
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!
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.
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.
You can try using --ignore-not-found=true
flag in command
kubectl delete deployments --ignore-not-found=true -n ${namespace} --all --grace-period=10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With