How to remove evicted Pods in Kubernetes/Openshift

Kubernetes

To remove Evicted Pods from Kubernetes use this command:

kubectl get pods — 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

Openshift

To remove Evicted Pods from Openshift use this command:

oc get pods — all-namespaces -o json | jq ‘.items[] | select(.status.reason!=null) | select(.status.reason | contains(“Evicted”)) | “oc delete pods \(.metadata.name) -n \(.metadata.namespace)”’ | xargs -n 1 bash -c

Learn more: https://sachsenhofer.io/how-to-remove-evicted-pods-in-kubernetes-openshift/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store