Search code examples
jenkinskuberneteskubectl

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

Solution

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

    kubectl delete deployments --ignore-not-found=true -n ${namespace} --all  --grace-period=10