搭配grep,awk強制刪除k8s中,所有非Running狀態的pod
kubectl get pods --all-namespaces -o wide | grep -v Running | grep -v NAME | awk '{print $1 " " $2}' | while read namespace podname; do kubectl delete -n $namespace pod $namespace --grace-period=0 --force; done
搭配grep,awk強制刪除k8s中,所有非Running狀態的pod
kubectl get pods --all-namespaces -o wide | grep -v Running | grep -v NAME | awk '{print $1 " " $2}' | while read namespace podname; do kubectl delete -n $namespace pod $namespace --grace-period=0 --force; done
看到一個不錯的範例
kubectl get pods --all-namespaces -o wide | awk '{print $1 " " $2}' | while read AA BB; do echo "$AA" "$BB"; done