-
Notifications
You must be signed in to change notification settings - Fork 0
/
wait-for-cluster.sh
43 lines (43 loc) · 1.41 KB
/
wait-for-cluster.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
37
38
39
40
41
42
43
#!/bin/sh
# Set KUBECONFIG
export KUBECONFIG=/home/lab/ocp4/auth/kubeconfig
# Wait for API to come online
until [ $(curl -k -s https://api.ocp4.example.com:6443/version?timeout=10s | jq -r '.major' | grep -v null | wc -l) -eq 1 ]
do
echo "Waiting for API..."
sleep 10
done
echo "API is up"
echo "Cluster version is $(oc get clusterversion version -o json | jq -r '.status.history[0].version')"
until [ not $(curl -k -s https://console-openshift-console.apps.ocp4.example.com >/dev/null) ]
do
echo "Waiting for router..."
sleep 10
done
echo "Router is up"
while true
do
code=$(curl -k -s https://oauth-openshift.apps.ocp4.example.com)
if [[ ! -z ${code} ]] && [[ "${code:0:1}" == "{" ]] && [[ $(echo $code | jq -r '.code') -eq 403 ]]
then
break
fi
echo "Waiting for authentication..."
sleep 10
done
echo "Authentication is ready"
for oper in ingress kube-apiserver
do
until [ $(oc get clusteroperators ${oper} -o json | jq -r '.status.conditions[]|select((.status=="True") and (.type=="Progressing"))'| wc -l) -eq 0 ]
do
echo "Waiting for the ${oper} operator to be ready..."
sleep 10
done
echo "The ${oper} operator is ready"
done
until [ $(oc get mcp -o json | jq -r '.items[].status.conditions[]|select((.status=="True") and (.type=="Updating"))' | wc -l) -eq 0 ]
do
echo "Waiting for Machine Config Operator to finish applying changes..."
sleep 10
done
echo "Machine Config Operator changes applied"