Last active
January 9, 2020 10:51
-
-
Save cooltoast/ed10a63eb96a6a450d164e0f0c6bcebe to your computer and use it in GitHub Desktop.
This file contains hidden or 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
kubectl get pods -a | grep Evicted | awk '{print $1}' | xargs kubectl delete pod |
Here is what I use:
kubectl get pods --all-namespaces --field-selector 'status.phase==Failed' -o json | kubectl delete -f -
@jconallen thanks for the comment. I have the -a
and pod
in my alias locally but forgot to update the gist
To delete evicted pods from all the namespaces, I use:
kubectl get pods --all-namespaces | grep Evicted | awk '{print $2 " --namespace=" $1}' | xargs -n 2 -d '\n' bash -c 'kubectl delete pod $0 $1'
This will split the parameters correctly for xargs when using the namespace option..
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think the -a is needed to allow evicted pods to return, and then the type of object (pod) needs to be added to delete.
kubectl get pods -a | grep Evicted | awk '{print $1}' | xargs kubectl delete pod