Skip to content

Instantly share code, notes, and snippets.

@onpaws
Created June 12, 2023 20:57
Show Gist options
  • Save onpaws/f94f60ba5cf6604f9465c948c89e9ceb to your computer and use it in GitHub Desktop.
Save onpaws/f94f60ba5cf6604f9465c948c89e9ceb to your computer and use it in GitHub Desktop.
Clean up evicted pods Kubernetes
# k8s will evict pods when resources get too tight, and by default retains a long history of evictions (either >12k, or 1000 on Rancher)
# This commmand will clean up the stale/evicted pods
kubectl get pods -A | grep Evicted | while read namespace pod rest; do kubectl delete pod $pod -n $namespace; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment