Skip to main content

Posts

Showing posts from March, 2020

Kubernetes - delete all pods with a certain status

"How to delete all pods with a status like Error" - that is a question I often get. The DevOps answer is a one-liner, filtering by status.reason and the status we want to query, es example: kubectl get po -A --all-namespaces -o json | jq '.items[] | select(.status.reason!=null) | select(.status.reason | contains("Evicted")) | "kubectl delete po \(.metadata.name) -n \(.metadata.namespace)"' | xargs -n 1 bash -c In that case we delete all pods with the Status "Evicted". But it works for every status based filtering.