forked from labring-actions/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwaitRunning.sh
executable file
·36 lines (31 loc) · 1.08 KB
/
waitRunning.sh
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
#!/bin/bash
set -e
readonly C_TIMEOUT=${1:-1}
readonly R_TIMEOUT=${2:-5}
echo "CheckCreating(timeout=$C_TIMEOUT), CheckRunning(timeout=$R_TIMEOUT)"
function checker() {
# for Creating
kubectl get pods -oname --all-namespaces | sort >"all.$HOSTNAME.pods"
until ! diff <(kubectl get pods -oname --all-namespaces | sort) "all.$HOSTNAME.pods" &>/dev/null; do
sleep 3
# timeout
if ! find . -type f -name "all.$HOSTNAME.pods" -mmin -"$C_TIMEOUT" | grep "all.$HOSTNAME.pods" &>/dev/null; then exit 8; fi
done
# for Running
until ! kubectl get pods --no-headers --all-namespaces | grep -vE Running &>/dev/null; do
sleep 9
if kubectl get pods --no-headers --all-namespaces | grep -vE Running; then
echo
fi
# timeout
if ! find . -type f -name "all.$HOSTNAME.pods" -mmin -"$R_TIMEOUT" | grep "all.$HOSTNAME.pods" &>/dev/null; then exit 88; fi
done
rm -f "all.$HOSTNAME.pods"
}
if kubectl version; then
kubectl get pods -owide --all-namespaces
kubectl get node -owide
checker
kubectl get pods -owide --all-namespaces
kubectl get node -owide
fi