Skip to content

Deleting not running pods

Why

Sometimes we can have a lot of pods that fail. A good example is on a GKE cluster running on preemptible instances

The AWS Alternative is Spot Instances

How

kubectl get pods --field-selector status.phase!=Running  -o name | xargs kubectl delete
kubectl get pods --field-selector status.phase!=Running -n <namespace> -o name | xargs kubectl delete -n <namespace>

Note

A better solution is to use something like kubectx + kubens


Want to make this site better? Open a PR or help fund hosting costs