k8s批量删除资源

  1. 查看有哪些不运行的pod
    image-20200926000641979

  2. 获取所有Evicted pod名称

[root@k8s-master tmp]# kubectl get pod --all-namespaces | grep Evicted  | awk '{print $2}'
gulimall-coupon-59595f8b8d-7sg5s
gulimall-coupon-59595f8b8d-8bwqv
gulimall-coupon-59595f8b8d-c6qk7
gulimall-coupon-59595f8b8d-gblg2
gulimall-coupon-59595f8b8d-hclst
gulimall-coupon-59595f8b8d-k2nf8
gulimall-coupon-59595f8b8d-klgr5
gulimall-coupon-59595f8b8d-kwbrz
gulimall-coupon-59595f8b8d-lrn26
gulimall-coupon-59595f8b8d-lvccg
gulimall-coupon-59595f8b8d-nswc9
gulimall-coupon-59595f8b8d-ntjg7
gulimall-coupon-59595f8b8d-pv8pr
gulimall-coupon-59595f8b8d-qqk95
gulimall-coupon-59595f8b8d-r8qs2
gulimall-coupon-59595f8b8d-sfpdb
gulimall-coupon-59595f8b8d-tqw6m
gulimall-coupon-59595f8b8d-v9vmb
gulimall-coupon-59595f8b8d-wvt7l
gulimall-coupon-59595f8b8d-xmgkz
gulimall-coupon-59595f8b8d-znv2l
gulimall-gateway-c8888b668-p8zdx
gulimall-order-7c4f596cfd-5d7vj
gulimall-order-7c4f596cfd-7v8bw
gulimall-order-7c4f596cfd-gc4kd
gulimall-order-7c4f596cfd-ghxxc
gulimall-order-7c4f596cfd-glmmb
gulimall-order-7c4f596cfd-h4ckl
gulimall-order-7c4f596cfd-l9fbk
gulimall-order-7c4f596cfd-lgb5v
gulimall-order-7c4f596cfd-x4q9z
gulimall-order-7c4f596cfd-xf784
gulimall-product-6dc475bd99-2k4v4
gulimall-product-6dc475bd99-45vv8
gulimall-product-6dc475bd99-4wjr4
gulimall-product-6dc475bd99-5tqbh
  1. 删除pod
[root@k8s-master tmp]# kubectl get pod --all-namespaces | grep Evicted  | awk '{print $2}' | xargs kubectl delete pod -n gulimall
pod "gulimall-coupon-59595f8b8d-7sg5s" deleted
pod "gulimall-coupon-59595f8b8d-8bwqv" deleted
pod "gulimall-coupon-59595f8b8d-c6qk7" deleted
pod "gulimall-coupon-59595f8b8d-gblg2" deleted
pod "gulimall-coupon-59595f8b8d-hclst" deleted
pod "gulimall-coupon-59595f8b8d-k2nf8" deleted
pod "gulimall-coupon-59595f8b8d-klgr5" deleted
pod "gulimall-coupon-59595f8b8d-kwbrz" deleted
pod "gulimall-coupon-59595f8b8d-lrn26" deleted
pod "gulimall-coupon-59595f8b8d-lvccg" deleted
pod "gulimall-coupon-59595f8b8d-nswc9" deleted
pod "gulimall-coupon-59595f8b8d-ntjg7" deleted
pod "gulimall-coupon-59595f8b8d-pv8pr" deleted
pod "gulimall-coupon-59595f8b8d-qqk95" deleted
pod "gulimall-coupon-59595f8b8d-r8qs2" deleted
pod "gulimall-coupon-59595f8b8d-sfpdb" deleted
pod "gulimall-coupon-59595f8b8d-tqw6m" deleted
pod "gulimall-coupon-59595f8b8d-v9vmb" deleted
pod "gulimall-coupon-59595f8b8d-wvt7l" deleted
pod "gulimall-coupon-59595f8b8d-xmgkz" deleted
pod "gulimall-coupon-59595f8b8d-znv2l" deleted
pod "gulimall-gateway-c8888b668-p8zdx" deleted
pod "gulimall-order-7c4f596cfd-5d7vj" deleted
pod "gulimall-order-7c4f596cfd-7v8bw" deleted
pod "gulimall-order-7c4f596cfd-gc4kd" deleted
pod "gulimall-order-7c4f596cfd-ghxxc" deleted
pod "gulimall-order-7c4f596cfd-glmmb" deleted
pod "gulimall-order-7c4f596cfd-h4ckl" deleted
pod "gulimall-order-7c4f596cfd-l9fbk" deleted
pod "gulimall-order-7c4f596cfd-lgb5v" deleted
pod "gulimall-order-7c4f596cfd-x4q9z" deleted

  1. 查看pod

image-20200926000800825

posted @ 2020-09-26 00:09  天宇轩-王  阅读(591)  评论(0编辑  收藏  举报