Created
November 30, 2018 17:59
-
-
Save gonzalesraul/037b60a4c5e49c4a796a2f813297bc3c to your computer and use it in GitHub Desktop.
Delete pods on Kubernetes with failed status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
#Delete in all namespaces (Evicted pods) | |
kubectl get po --field-selector=status.phase==Failed --all-namespaces --no-headers -o=custom-columns=k:kind,n:.metadata.name,ns:.metadata.namespace|while read k n ns;do kubectl delete $k/$n -n $ns; done | |
#Delete specific namespace | |
kubectl get po --field-selector=status.phase==Failed -n ${NAMESPACE} --no-headers -o=custom-columns=k:kind,n:.metadata.name,ns:.metadata.namespace|while read k n ns;do kubectl delete $k/$n -n $ns; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment