This page looks best with JavaScript enabled

Kubernetes Batch Operation Commands

 ·  ☕ 1 min read

1. Delete Pods in the Evicted State in Bulk

1
kubectl get pods --all-namespaces -o wide | grep Evicted | awk '{print $1,$2}' | xargs -L1 kubectl delete pod -n

2. Delete Pods in a Given State in a Given Namespace in Bulk

Using field-selectors, you can delete Pods in a given state in a given namespace.

1
kubectl get pods --field-selector=status.phase!=Running -n default | cut -d' ' -f 1 | xargs kubectl delete pod -n default

WeChat Official Account
WRITTEN BY
WeChat Official Account