使用kubectl中的强制删除pod命令
1.使用kubectl中的强制删除命令
kubectl delete pod nginx -n mmp --force --grace-period=0
2.删除非正常的pod
a.查询出所有要删除的podName
kubectl get po | grep Unknown | awk '{print $1}'
b.批量删除
kubectl delete pod `kubectl get po | grep Unknown | awk '{print $1}'` --force --grace-period=0
或者
kubectl get pods -n prod| grep Evicted | awk '{print $1}' | xargs kubectl delete pod -n prod
c. 删除所有异常的pods
kubectl -n platform delete pod `kubectl get po --all-namespaces=true | grep 'Evicted\|Terminating\|Unknown' | awk '{print $1}'` --force --grace-period=0
kubectl delete pod `kubectl get po -napp-prod| grep Evicted | awk '{print $1}'` -napp-prod --force --grace-period=0