shell脚本逐个杀死k8s中某个应用的pod

#!/bin/bash

pod01=`kubectl get pod -o wide -n weifeng-system|grep official-ui-node-prod|awk -F : 'NR==1'|awk -F " " '{print $1}'`
pod02=`kubectl get pod -o wide -n weifeng-system|grep official-ui-node-prod|awk -F : 'NR==2'|awk -F " " '{print $1}'`
pod03=`kubectl get pod -o wide -n weifeng-system|grep official-ui-node-prod|awk -F : 'NR==3'|awk -F " " '{print $1}'`

kubectl delete pod $pod01  -n weifeng-system

sleep 60

kubectl delete pod $pod02  -n weifeng-system

sleep 60

kubectl delete pod $pod03  -n weifeng-system

sleep 20
 

node_prod_status=`kubectl get pod -o wide -n weifeng-system|grep official-ui-node-prod|awk -F " " '{print $3}'|grep -ci "Running"`


if [ $node_prod_status -eq 3 ];then

    echo -e "\033[32m[ the application official-ui-node-pre successfully deployed  ]\033[0m"

else
    echo -e "\033[31m\033[01m[ the application official-ui-node-pre deploy failed  ]\033[0m"

fi

  

posted @ 2019-01-11 14:25  Oops!#  阅读(1589)  评论(0编辑  收藏  举报