Yes, someday you may need this.
- Do it soft way.
This one takes some time to finish. Depends on the number of POD in your cluster.
kubectl get ns -o name|awk -F/ {'print $2'} |grep -vE "^kube-system$"| xargs -I{} kubectl -n {} rollout restart deploy
kubectl get ns -o name|awk -F/ {'print $2'} |grep -vE "^kube-system$"| xargs -I{} kubectl -n {} rollout restart ds
kubectl get ns -o name|awk -F/ {'print $2'} |grep -vE "^kube-system$"| xargs -I{} kubectl -n {} rollout restart sts
2. Do it hard way.
#!/bin/bashfor i in $(kubectl get pods -A|grep -vE "^NAMESPACE|^kube-system"|shuf|awk {'print $1","$2'})
doIFS=', ' read -r -a arr <<< "$i"echo "NameSpace: " ${arr[0]}
echo "Pod ID: " ${arr[1]}echo "kubectl delete pod ${arr[1]} -n ${arr[0]}"
kubectl delete pod ${arr[1]} -n ${arr[0]} &>/dev/null &#little sleep, reduce load to api-server and scheduler
sleep 0.5done
Good luck.