środa, 6 marca 2019

Prune all evicted or failed Pods

Sometimes you might have a lot of pods in Evicted or other state which requires manual deletion by cluster administrator. This is how you can do that with single command:  

for n in $(oc get projects --no-headers=true | awk '{print $1}'); do echo $n; for pod in $(oc get pods -n $n --no-headers=true | grep "Evicted" | awk '{print $1}'); do oc delete pod ${pod} -n ${n}; done; done;

Similarly you can delete with single command all pods in CrashLoopBackOff state:

for n in $(oc get projects --no-headers=true | awk '{print $1}'); do echo $n; for pod in $(oc get pods -n $n --no-headers=true | grep "CrashLoopBackOff" | awk '{print $1}'); do oc delete pod ${pod} -n ${n}; done; done;


Brak komentarzy:

Prześlij komentarz