# k8s 中如何删除所有 Evicted 状态的 pod

Issue

欢迎在 Issue 中交流与讨论: Issue 355

Author

回答者: shfshanyue

$ kubectl get pods
NAME                                             READY   STATUS             RESTARTS   AGE
cert-manager-5d8fd69d88-4nxw5                    1/1     Running            0          63d
cert-manager-5d8fd69d88-f7f2w                    0/1     Evicted            0          63d
cert-manager-5d8fd69d88-mpgqq                    0/1     Evicted            0          63d
cert-manager-5d8fd69d88-s7dtg                    0/1     Evicted            0          232d
cert-manager-5d8fd69d88-vdmrx                    0/1     Evicted            0          63d
cert-manager-5d8fd69d88-zlpv4                    0/1     Evicted            0          63d
cert-manager-cainjector-755bbf9c6b-455nm         0/1     Evicted            0          63d

可通过 kubectl get pods 来找到 Evicted 状态的 POD,通过 awkkubectl delete pod 选中目标 pod 并删除,命令如下

$  kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod

扫码关注公众号全栈成长之路,并发送

即可在关注期间无限制浏览本站全部文章内容

你也可以在文章关于回复公众号扫码解锁全站的技术实现中获得解锁代码,永久解锁本站全部文章

Last Updated: 6/28/2020, 4:58:35 PM