Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bgarcial/9639648a6183e16512e87364cc019ad4 to your computer and use it in GitHub Desktop.
Save bgarcial/9639648a6183e16512e87364cc019ad4 to your computer and use it in GitHub Desktop.
Delete evicted pods from all namespaces (also ImagePullBackOff and ErrImagePull)
#!/bin/sh
# based on https://gist.github.com/ipedrazas/9c622404fb41f2343a0db85b3821275d
# delete all evicted pods from all namespaces
kubectl get pods --all-namespaces | grep Evicted | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod
# delete all containers in ImagePullBackOff state from all namespaces
kubectl get pods --all-namespaces | grep 'ImagePullBackOff' | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod
# delete all containers in ImagePullBackOff or ErrImagePull or Evicted state from all namespaces
kubectl get pods --all-namespaces | grep -E 'ImagePullBackOff|ErrImagePull|Evicted' | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment