Tuesday, May 8, 2018

Delete all evicted pods in openshift


Delete all evicted pods in openshift


# for the current namespace
eval "$(oc get pods -o json | jq -r '.items[] | select(.status.phase == "Failed" and .status.reason == "Evicted") | "oc delete pod --namespace " + .metadata.namespace + " " + .metadata.name')"


# for all namespaces
eval "$(oc get pods -o json --all-namespaces | jq -r '.items[] | select(.status.phase == "Failed" and .status.reason == "Evicted") | "oc delete pod --namespace " + .metadata.namespace + " " + .metadata.name')"


Here,  jq - commandline JSON processor
You need to install jq first.


ref: https://stackoverflow.com/questions/46419163/what-will-happen-to-evicted-pods-in-kubernetes 

No comments:

Post a Comment