qcloud.sh
1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
echo "para clusterId is : $1"
echo "para serviceName is : $2"
echo "para containerName is : $3"
echo "para imageInfo is : $4"
clusterInfo="system-$1"
serviceName=$2
containerName=$3
imageInfo="ccr.ccs.tencentyun.com/$4"
## 切换当前的工作空间
/usr/local/bin/kubectl config use-context $clusterInfo
/usr/local/bin/kubectl get pods
## 更新镜像信息
/usr/local/bin/kubectl set image deployment/$serviceName $containerName=$imageInfo
## 等待30s后校验
waitnum=1
while [ $waitnum -le 4 ]
do
let waitnum=waitnum+1
echo "print the cluster info "
/usr/local/bin/kubectl get pods |grep $serviceName
sleep 5
done
## check service is done
num=1
while [ $num -le 60 ]
do
echo "begin check the service is done ,the check number is :$num "
if [ "$num" == 60 ];then
echo "over the check number ,the check number is :$num "
exit 1
fi
let num=num+1
echo "print the cluster info "
/usr/local/bin/kubectl get pods |grep $serviceName
newrunning=$(/usr/local/bin/kubectl get pods |grep "$serviceName" |awk '$3!="Running"' |wc -l)
newredy=$(/usr/local/bin/kubectl get pods |grep "$serviceName" |awk '$2!="1/1" || $2!="2/2"' |wc -l)
if [ "$newrunning" == 0 && "$newredy" == 0 ];then
echo "end with the cluster check the publish is ok"
break;
fi
sleep 10
done