k8s批量操作


批量删除pod

sh pod.sh ImagePullBackOff
```bash
#!/bin/bash

RED_COLOR='\E[1;31m'
GREEN_COLOR='\E[1;32m'
YELLOW_COLOR='\E[1;33m'
RES='\E[0m'

#输入退出类型,不输入默认删除ImagePullBackOff
i=$0
i=${1-$0}

kubectl get pods --all-namespaces|grep $i|awk '{print $1,$2}'|while read -r line
 do
  namespaces=`echo $line|awk '{print $1}'`
  podname=`echo $line|awk '{print $2}'`
  echo -e  "${GREEN_COLOR} NAMESPACE: $namespaces PODNAME: $podname ${RES}"

  kubectl delete pod $podname -n $namespaces
  done