Skip to content

Instantly share code, notes, and snippets.

@cooltoast
Last active January 9, 2020 10:51
Show Gist options
  • Save cooltoast/ed10a63eb96a6a450d164e0f0c6bcebe to your computer and use it in GitHub Desktop.
Save cooltoast/ed10a63eb96a6a450d164e0f0c6bcebe to your computer and use it in GitHub Desktop.
kubectl get pods -a | grep Evicted | awk '{print $1}' | xargs kubectl delete pod
@GMartinez-Sisti
Copy link

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