forked from miyurud/jasminegraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-k8s.sh
executable file
·165 lines (140 loc) · 4.16 KB
/
start-k8s.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/bash
set -e
TIMEOUT_SECONDS=60
if [ $1 == "clean" ]; then
kubectl delete deployments -l application=jasminegraph
kubectl delete services -l application=jasminegraph
kubectl delete pvc -l application=jasminegraph
kubectl delete pv -l application=jasminegraph
exit 0
fi
META_DB_PATH=${META_DB_PATH}
PERFORMANCE_DB_PATH=${PERFORMANCE_DB_PATH}
DATA_PATH=${DATA_PATH}
LOG_PATH=${LOG_PATH}
AGGREGATE_PATH=${AGGREGATE_PATH}
NO_OF_WORKERS=${NO_OF_WORKERS}
ENABLE_NMON=${ENABLE_NMON}
MAX_COUNT=${MAX_COUNT}
while [ $# -gt 0 ]; do
if [[ $1 == *"--"* ]]; then
param="${1/--/}"
declare $param="$2"
echo $1 "=" $2
fi
shift
done
if [ -z "$META_DB_PATH" ]; then
echo "META_DB_PATH SHOULD BE SPECIFIED"
exit 1
fi
if [ -z "$PERFORMANCE_DB_PATH" ]; then
echo "PERFORMANCE_DB_PATH SHOULD BE SPECIFIED"
exit 1
fi
if [ -z "$DATA_PATH" ]; then
echo "DATA_PATH SHOULD BE SPECIFIED"
exit 1
fi
if [ -z "$LOG_PATH" ]; then
echo "LOG_PATH SHOULD BE SPECIFIED"
exit 1
fi
if [ -z "$NO_OF_WORKERS" ]; then
NO_OF_WORKERS="2"
fi
if [ -z "$ENABLE_NMON" ]; then
ENABLE_NMON="false"
fi
if [ -z "$MAX_COUNT" ]; then
MAX_COUNT="4"
fi
kubectl apply -f ./k8s/rbac.yaml
kubectl apply -f ./k8s/pushgateway.yaml
# wait until pushgateway starts listening
cur_timestamp="$(date +%s)"
end_timestamp="$((cur_timestamp + TIMEOUT_SECONDS))"
spin="/-\|"
i=0
while true; do
if [ "$(date +%s)" -gt "$end_timestamp" ]; then
echo "Timeout"
exit 1
fi
pushgatewayIP="$(kubectl get services |& grep pushgateway | tr '\t' ' ' | tr -s ' ' | cut -d ' ' -f 3)"
if [ ! -z "$pushgatewayIP" ]; then
break
fi
printf "Waiting pushgateway to start [%c] \r" "${spin:i++%${#spin}:1}"
sleep .2
done
pushgateway_address="${pushgatewayIP}:9091" envsubst <"./k8s/prometheus.yaml" | kubectl apply -f -
cur_timestamp="$(date +%s)"
end_timestamp="$((cur_timestamp + TIMEOUT_SECONDS))"
while true; do
if [ "$(date +%s)" -gt "$end_timestamp" ]; then
echo "Timeout"
exit 1
fi
prometheusIP="$(kubectl get services |& grep prometheus | tr '\t' ' ' | tr -s ' ' | cut -d ' ' -f 3)"
if [ ! -z "$prometheusIP" ]; then
break
fi
printf "Waiting prometheus to start [%c] \r" "${spin:i++%${#spin}:1}"
sleep .2
done
pushgateway_address="${pushgatewayIP}:9091/" \
prometheus_address="${prometheusIP}:9090/" \
max_worker_count="${MAX_COUNT}" \
envsubst <"./k8s/configs.yaml" | kubectl apply -f -
metadb_path="${META_DB_PATH}" \
performancedb_path="${PERFORMANCE_DB_PATH}" \
data_path="${DATA_PATH}" \
log_path="${LOG_PATH}" \
aggregate_path="${AGGREGATE_PATH}" \
envsubst <"./k8s/volumes.yaml" | kubectl apply -f -
no_of_workers="${NO_OF_WORKERS}" \
enable_nmon="${ENABLE_NMON}" \
envsubst <"./k8s/master-deployment.yaml" | kubectl apply -f -
# Wait till all pods are running
cur_timestamp="$(date +%s)"
end_timestamp="$((cur_timestamp + TIMEOUT_SECONDS))"
while true; do
if [ "$(date +%s)" -gt "$end_timestamp" ]; then
for pod in $(kubectl get pods -o jsonpath='{.items[*].metadata.name}'); do
kubectl describe pod "$pod"
done
echo "Pods are not running"
exit 1
fi
set +e
pods_status="$(kubectl get pods | grep -v 'STATUS' | grep -v 'Running')"
set -e
if [ -z "$pods_status" ]; then
echo "All pods are running"
break
fi
echo "----------------------------------------"
echo "Waiting for pods to be running"
echo "----------------------------------------"
echo "$pods_status"
sleep 5
done
# wait until master starts listening
cur_timestamp="$(date +%s)"
end_timestamp="$((cur_timestamp + TIMEOUT_SECONDS))"
while true; do
if [ "$(date +%s)" -gt "$end_timestamp" ]; then
echo "Timeout"
exit 1
fi
masterIP="$(kubectl get services |& grep jasminegraph-master-service | tr '\t' ' ' | tr -s ' ' | cut -d ' ' -f 3)"
if [ ! -z "$masterIP" ]; then
echo
echo "Connect to JasmineGraph at $masterIP:7777"
echo
break
fi
printf "Waiting JasmineGraph to start [%c] \r" "${spin:i++%${#spin}:1}"
sleep .2
done