Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pindank/d3f6c05c6aef0fdc4f9455606c0822a0 to your computer and use it in GitHub Desktop.
Save pindank/d3f6c05c6aef0fdc4f9455606c0822a0 to your computer and use it in GitHub Desktop.

Revisions

  1. pindank revised this gist Aug 10, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion delete-evicted-pods-all-namespaces.sh
    Original file line number Diff line number Diff line change
    @@ -8,4 +8,4 @@ kubectl get pods --all-namespaces | grep Evicted | awk '{print $2 " --namespace=
    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
    kubectl get pods --all-namespaces | grep -E 'ImagePullBackOff|ErrImagePull|Evicted|CrashLoopBackOff' | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod
  2. @psxvoid psxvoid created this gist Aug 6, 2018.
    11 changes: 11 additions & 0 deletions delete-evicted-pods-all-namespaces.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    #!/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