-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwaitForPod.sh
More file actions
61 lines (51 loc) · 1.64 KB
/
waitForPod.sh
File metadata and controls
61 lines (51 loc) · 1.64 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
52
53
54
55
56
57
58
59
60
61
#Licensed Materials - Property of IBM
#(C) Copyright IBM Corp. 2016, 2017. All Rights Reserved.
#US Government Users Restricted Rights - Use, duplication or
#disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <namespace>"
exit 1
fi
namespace=$1
success="false"
for j in {1..10}
do
i=0
arr=()
#`kubectl get pods -n ${namespace} > status.txt`
`kubectl get -n ${namespace} pods > status.txt`
while read LINE
do
status=`echo $LINE | awk '{print $3}'`
#Skip the first iteration
if [ "$status" == "STATUS" ]
then
continue
fi
#Check which services are not in running state
if [ "$status" != "Running" ]
then
microservice=`echo $LINE | awk '{print $1}'`
arr[$i]=$microservice
let i++
echo "$microservice is not running"
fi
done < status.txt
#After each iteration check if all the services are in running state or wait for 60s and try again
if [ $i -gt 0 ]
then
echo "Wait for 10 Seconds and then check again"
sleep 10
else
echo "All the services are in running state"
success="true"
exit 0
fi
done
if [ $success == "false" ]
then
echo "Services are not in running state even after multiple attempts"
echo -e "\nFollowing services are not running : \n${arr[@]}"
exit 1
fi