无意中测试功能的时候发现配置错误导致请求一次就会创建一个pod,后来写了一个脚本导致创建了一千多个pod,但是这些pod又是没有用的,删除是个麻烦事,如果一个一个的删除太麻烦了,批量删除又容易把有用的删除掉,所以这里就用到命令进行批量删除了,下面先看看我的无用pod.
[root@www.wulaoer.org ingress]# kubectl get pod -n ops-team NAME READY STATUS RESTARTS AGE grafana-565d647f8b-p87cr 1/1 Running 0 5h56m nginx-r59k2r-846c7f9bf6-24dr4 0/1 Pending 0 3m22s nginx-r59k2r-846c7f9bf6-25l9d 0/1 Pending 0 3m54s nginx-r59k2r-846c7f9bf6-25z6k 0/1 Pending 0 3m34s nginx-r59k2r-846c7f9bf6-268nb 0/1 Pending 0 4m39s nginx-r59k2r-846c7f9bf6-27hq9 0/1 Pending 0 3m36s nginx-r59k2r-846c7f9bf6-27mpq 0/1 Pending 0 4m23s nginx-r59k2r-846c7f9bf6-27wcr 0/1 Pending 0 3m43s nginx-r59k2r-846c7f9bf6-27whb 0/1 Pending 0 3m32s nginx-r59k2r-846c7f9bf6-282bv 0/1 Pending 0 4m20s nginx-r59k2r-846c7f9bf6-28qlw 0/1 Pending 0 3m34s nginx-r59k2r-846c7f9bf6-2ffq7 0/1 Pending 0 3m33s nginx-r59k2r-846c7f9bf6-2hz99 0/1 Pending 0 3m45s nginx-r59k2r-846c7f9bf6-2l75t 0/1 Pending 0 3m23s nginx-r59k2r-846c7f9bf6-2mwwh 0/1 Pending 0 3m40s nginx-r59k2r-846c7f9bf6-2n84b 0/1 Pending 0 3m21s nginx-r59k2r-846c7f9bf6-2w9zs 0/1 Pending 0 3m20s nginx-r59k2r-846c7f9bf6-2x4ml 0/1 Pending 0 3m47s nginx-r59k2r-846c7f9bf6-2xljz 0/1 Pending 0 3m41s nginx-r59k2r-846c7f9bf6-44csl 0/1 Pending 0 3m33s
这里只展示部分,创建的还有没有起起来,所以删除的时候不能根据状态筛选,这里因为服务名字都一样就选择筛选后删除。
[root@www.wulaoer.org ingress]# kubectl get pod -n ops-team | grep nginx-r59k2r-846c7f9bf6 | awk '{print $1}' | xargs kubectl delete pod -n ops-team pod "nginx-r59k2r-846c7f9bf6-24dr4" deleted pod "nginx-r59k2r-846c7f9bf6-25l9d" deleted pod "nginx-r59k2r-846c7f9bf6-25z6k" deleted pod "nginx-r59k2r-846c7f9bf6-268nb" deleted pod "nginx-r59k2r-846c7f9bf6-27hq9" deleted pod "nginx-r59k2r-846c7f9bf6-27mpq" deleted pod "nginx-r59k2r-846c7f9bf6-27wcr" deleted pod "nginx-r59k2r-846c7f9bf6-27whb" deleted pod "nginx-r59k2r-846c7f9bf6-282bv" deleted pod "nginx-r59k2r-846c7f9bf6-28qlw" deleted pod "nginx-r59k2r-846c7f9bf6-2ffq7" deleted pod "nginx-r59k2r-846c7f9bf6-2hz99" deleted
这里所有nginx开头的服务就可以自动删除了,因为较多,所以删除需要等一会,删除后就基本没有问题了。没有了看些其他的吧。
您可以选择一种方式赞助本站
支付宝扫一扫赞助
微信钱包扫描赞助
赏