Skip to content

Instantly share code, notes, and snippets.

@gonzalesraul
Created November 30, 2018 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gonzalesraul/037b60a4c5e49c4a796a2f813297bc3c to your computer and use it in GitHub Desktop.
Save gonzalesraul/037b60a4c5e49c4a796a2f813297bc3c to your computer and use it in GitHub Desktop.
Delete pods on Kubernetes with failed status
#!/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