批量删除failed pod

kubectl get pods --field-selector=status.phase=Failed --all-namespaces
export ns=kube-system
kubectl get pods --field-selector=status.phase=Failed -n $ns | cut -d' ' -f 1 | xargs kubectl delete pod -n $ns
kubectl get pods --field-selector=status.phase=Failed -n kube-system | cut -d' ' -f 1 | xargs kubectl delete pod -n kube-system
kubectl get pods --field-selector=status.phase=Failed -n cattle-system | cut -d' ' -f 1 | xargs kubectl delete pod -n cattle-system

最后更新于