Forked from ipedrazas/gist:9c622404fb41f2343a0db85b3821275d
Created
October 28, 2021 07:02
-
-
Save getsueineko/7c249d9981f6246cd7c911bf715f5229 to your computer and use it in GitHub Desktop.
Delete evicted pods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Options:
eval "$(oc get pods --all-namespaces -o json | jq -r '.items[] | select(.status.phase == "Failed" and .status.reason == "Evicted") | "oc delete pod --namespace " + .metadata.namespace + " " + .metadata.name')"
pwsh
Foreach( $x in (kubectl get po --all-namespaces --field-selector=status.phase=Failed --no-headers -o custom-columns=:metadata.name)) {kubectl delete po $x --all-namespaces }
bash
kubectl get po --all-namespaces --field-selector=status.phase=Failed --no-headers -o custom-columns=:metadata.name | xargs kubectl delete po --all-namespaces