K8S一键停起副本数
cat start_k8s.sh #!/bin/bash for i in `cat /tmp/replicas.txt`;do kubectl scale deployment `echo $i | awk -F ":" '{print $2}'` -n `echo $i | awk -F ":" '{print $1}'` --replicas `awk -F ":" '{print $3}'`;done >/tmp/k8s_start.log exit 0 cat stop_k8s.sh #!/bin/bash kubectl get deployment -A | egrep -v "monitoring|elk|kafka|apollo|kube-system|0/0" | awk '{print $1":"$2":"$5}' | sed '1d' >/tmp/replicas.txt for i in `cat /tmp/replicas.txt`;do kubectl scale deployment `echo $i | awk -F ":" '{print $2}'` -n `echo $i | awk -F ":" '{print $1}'` --replicas 0;done >/tmp/k8s_stop.log exit 0
使劲折腾才会有更好的结果!!!!
如有不对请不吝赐教,感谢!
转载请注明出处!