Skip to content

Instantly share code, notes, and snippets.

View saikatharryc's full-sized avatar
🏠
Helming from home

Saikat Chakrabortty saikatharryc

🏠
Helming from home
View GitHub Profile
@saikatharryc
saikatharryc / delete-evicted-pods-all-namespaces.sh
Created March 2, 2020 02:47 — forked from psxvoid/delete-evicted-pods-all-namespaces.sh
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