How to delete Evicted Kubernetes pods


If you have a bunch of pesky "Evicted" Kubernetes pods (kubectl get pods), run the following command to clean those suckas up.

kubectl get pods -a --all-namespaces -o json | jq '.items[] | select(.status.reason!=null) | select(.status.reason | contains("Evicted")) | "kubectl delete pods \(.metadata.name) -n \(.metadata.namespace)"' | xargs -n 1 bash -c