Skip to content

Cheatsheet

Switch namespace

kubectl config set-context --current --namespace=<New Namespace>

Switch Cluster/Context

kubectl config set-context <New Context>

Delete broken pods

kubectl get po --all-namespaces --field-selector 'status.phase==Failed' -o json | kubectl delete -f -

kubectl get po --all-namespaces --field-selector 'status.phase==Evicted' -o json | kubectl delete -f -

kubectl get po --all-namespaces --field-selector 'status.phase==Pending' -o json | kubectl delete -f -

Source: https://gist.github.com/ipedrazas/9c622404fb41f2343a0db85b3821275d?permalink_comment_id=3019247#gistcomment-3019247