k8s批量删除Evicted Pods

2023-04-24  本文已影响0人  彩色的炮灰
kubectl -n gotion get pods | grep Evicted |awk '{print$1}' |xargs kubectl -n gotion delete pods

1、查询pod状态

[root@k8s_master prom]# kubectl -n kube-system get pods | grep Evicted
coredns-67cb7b5f46-2crxg                0/1     Evicted   0          4h56m
coredns-67cb7b5f46-2ds7n                0/1     Evicted   0          4h56m
coredns-67cb7b5f46-2pzw5                0/1     Evicted   0          4h56m
coredns-67cb7b5f46-4f8nm                0/1     Evicted   0          166m
coredns-67cb7b5f46-4gncz                0/1     Evicted   0          10h
coredns-67cb7b5f46-4lnw2                0/1     Evicted   0          166m
coredns-67cb7b5f46-4smp6                0/1     Evicted   0          166m
coredns-67cb7b5f46-5hx49                0/1     Evicted   0          166m
coredns-67cb7b5f46-6jxqn                0/1     Evicted   0          166m
coredns-67cb7b5f46-6qh9z                0/1     Evicted   0          166m
coredns-67cb7b5f46-6rn4c                0/1     Evicted   0          10h
coredns-67cb7b5f46-7jsth                0/1     Evicted   0          10h
coredns-67cb7b5f46-7mzvb                0/1     Evicted   0          166m
coredns-67cb7b5f46-92t2k                0/1     Evicted   0          4h56m
coredns-67cb7b5f46-9jqdm                0/1     Evicted   0          10h
coredns-67cb7b5f46-9rxsc                0/1     Evicted   0          4h56m
coredns-67cb7b5f46-9xmkk                0/1     Evicted   0          166m

2、发现有很多 “Evicted” 状态的pod
问题原因:这是由于node节点的磁盘或内存资源不够后将现有的pod进行了驱赶。

3、批量删除所有“Evicted”状态的pod即可

[root@k8s_master ]# kubectl -n kube-system  get pods | grep Evicted |awk '{print$1}'|xargs kubectl -n kube-system delete pods

PS: kubectl -n kube-system get pods #指定pod所在的命名空间
执行完成后,成功删除全部Evicted状态的Pods

参考地址:https://cloud.tencent.com/developer/article/2086456

上一篇下一篇

猜你喜欢

热点阅读