-
Notifications
You must be signed in to change notification settings - Fork 11
/
elastickonductor.sh
executable file
·448 lines (416 loc) · 15.1 KB
/
elastickonductor.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
#!/bin/bash
$(mkdir ./logs 2>/dev/null)
LOG_LOCATION=./logs
nowtime=`date +"%m_%d_%Y_%s"`
oneclickv=2.1.11
usage() {
echo
echo
echo "Usage: $0 [OPTIONS]"
echo
echo "Cloud Platforms:"
printf " %-28s %s\n" "-c [aws | azure | gcp | ess]" "Choose the cloud platform."
echo
echo "Deployment Options:"
printf " %-28s %s\n" "-b [all | k8s | eck | otel]" "Choose component to deploy."
printf " %-28s %s\n" "-d" "Destroy all components."
printf " %-28s %s\n" "-de" "Destroy eck."
printf " %-28s %s\n" "-do" "Destroy otel."
printf " %-28s %s\n" "--openebs" "Enable OpenEBS"
echo
echo "Deployment Information Options:"
printf " %-28s %s\n" "-inf" "Get cluster infrastructure information."
printf " %-28s %s\n" "-i" "Get ECK & infrastructure information."
echo
echo "Miscellaneous Options:"
printf " %-28s %s\n" "-k" "Set kubectl context."
echo
printf " %-28s %s\n" "-h" "Display this help message."
echo
exit 0;
}
cleanup() {
createmode=false
k8sonly=false
destroy=false
createModeArg=NA
cloud=NA
openebs_option=""
getClusterInfo=false
getInfraInfo=false
destroyeck=false
createOtel=false
destroyOtel=false
installclient=false
setKubectl=false
eckonly=false
}
cleanup
# process command line arguments
while [[ "$#" -gt 0 ]]; do
case "$1" in
-c|--cloud)
shift
if [[ "$1" == "aws" ]]; then
echo "Cloud: AWS"
cloud="aws"
elif [[ "$1" == "azure" ]]; then
echo "Cloud: Azure"
cloud="azure"
elif [[ "$1" == "gcp" ]]; then
echo "Cloud: GCP"
cloud="gcp"
elif [[ "$1" == "ess" ]]; then
echo "Cloud: ESS"
cloud="ess"
else
echo "Not a valid cloud provider. Use: aws|azure|gcp"
exit 1
fi
shift
;;
-b|--build)
shift
createModeArg="$1"
createmode=true
if [[ "$1" == "all" ]]; then
echo "Build Mode = ALL"
createAll=true
elif [[ "$1" == "k8s" ]]; then
echo "Build Mode = K8s Only"
k8sonly=true
elif [[ "$1" == "otel" ]]; then
echo "Build Mode = K8s & Otel"
k8sonly=true
createOtel=true
elif [[ "$1" == "eck" ]]; then
echo "Build Mode = ECK only"
eckonly=true
createOtel=true
else
echo "Not a valid build option. Use: all, k8s, eck, or otel"
exit 1
fi
shift
;;
--openebs)
echo "Enable OpenEBS"
openebs_enabled="--openebs"
shift
;;
-i|--getClusterInfo)
echo "Get Cluster Info"
getClusterInfo=true
shift
;;
-inf|--getInfraInfo)
echo "Get Infra Info"
getInfraInfo=true
shift
;;
-k|--setkubectl)
echo "Set kubectl"
setKubectl=true
shift
;;
-ic|--installclient)
echo "Install Client"
installclient=true
shift
;;
-d|--destroy)
echo "Destroy all"
destroy=true
shift
;;
-de|--destroyeck)
echo "Destroy ECK"
destroyeck=true
shift
;;
-do|--destroyotel)
echo "Destroy Otel"
destroyOtel=true
shift
;;
-h|--help)
usage
;;
-v|--version)
echo
echo "Version $oneclickv"
exit 0
;;
*)
usage
break
;;
esac
done
chmod 700 ./aws/1ClickAWS.sh
chmod 700 ./aws/getClusterInfo.sh
chmod 700 ./gcp/1ClickGCP.sh
chmod 700 ./gcp/getClusterInfo.sh
chmod 700 ./azure/1ClickAzure.sh
chmod 700 ./azure/getClusterInfo.sh
exec > >(tee -i $LOG_LOCATION/1Click_${cloud}_${nowtime}.log)
exec 2>&1
echo "Log Location: [ $LOG_LOCATION ]"
set -e
if [ $installclient == true ] ; then
echo "Installing 1ClickECK Client"
(cd scripts; bash ./1ClickECK-client-install.sh)
exit 0
fi
set +e
if [ $createmode != true ] && [ $destroy != true ] && [ $k8sonly != true ] && [ $getClusterInfo != true ] && [ $getInfraInfo != true ] && [ $destroyeck != true ] && [ $setKubectl != true ] && [ $destroyOtel != true ]; then
usage
fi
if [ $destroy == true ] && [ $createmode == true ] ; then
echo "create and destroy cant be set together" >&2
exit 1
fi
if [ $destroyeck == true ] && [ $createmode == true ] ; then
echo "create and destroy cant be set together" >&2
exit 1
fi
if [ $destroy == true ] && [ $cloud == "NA" ] ; then
echo "Destroy requires -c" >&2
exit 1
fi
if [ $createmode == true ] && [ $cloud == "NA" ] ; then
echo "Build requires -c" >&2
exit 1
fi
if [ $destroy == true ] && [ $k8sonly == true ] ; then
echo 'create and destroy cant be set together' >&2
exit 1
fi
echo
echo
echo
echo version $oneclickv
echo author: sunile manjee
echo
echo Welcome to...
echo " _ _ _ _ _ _ ";
echo " | | | | (_) | | | | | | ";
echo " ___ | | __ _ ___ | |_ _ ___ ______ | | __ ___ _ __ __| | _ _ ___ | |_ ___ _ __ ";
echo " / _ \| | / _\` |/ __|| __|| | / __||______|| |/ // _ \ | '_ \ / _\` || | | | / __|| __|/ _ \ | '__|";
echo " | __/| || (_| |\__ \| |_ | || (__ | <| (_) || | | || (_| || |_| || (__ | |_| (_) || | ";
echo " \___||_| \__,_||___/ \__||_| \___| |_|\_\\___/ |_| |_| \__,_| \__,_| \___| \__|\___/ |_| ";
echo " ";
echo " ";
#https://patorjk.com/software/taag/#p=display&h=1&v=1&c=echo&f=Chiseled&t=1ClickECK#
set -e
start=$SECONDS
echo "createmode $createmode"
echo "k8sonly $k8sonly"
echo "eckonly $eckonly"
echo "destroy $destroy"
echo "createModeArg $createModeArg"
echo "cloud $cloud"
echo "openebs_enabled $openebs_enabled"
echo "getClusterInfo $getClusterInfo"
echo "destroyeck $destroyeck"
echo "createOtel $createOtel"
echo "destroyOtel $destroyOtel"
export KUBE_CONFIG_PATH=~/.kube/config
if [ $cloud == "aws" ]; then
(cd aws; python prechecks.py)
if [ $getClusterInfo == true ]; then
echo "Get cluster Info"
(cd ./aws; bash ./getClusterInfo.sh)
duration=$(( SECONDS - start ))
elif [ $getInfraInfo == true ]; then
echo "Get Infra Info"
(cd ./aws/eks; bash ./getClusterInfo.sh)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [ $setKubectl == true ]; then
echo "Set kubectl"
(cd ./aws/eks; bash ./setkubectl.sh)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [ $createmode == true ] && [ $k8sonly == false ]; then
echo "1ClickECK.sh: calling 1ClickAWS.sh with all"
(cd ./aws; bash ./1ClickAWS.sh -b all $openebs_enabled)
duration=$(( SECONDS - start ))
echo 1ClickECK.sh: Total deployment time in seconds: $duration
elif [ $createmode == true ] && [ $k8sonly == true ] && [ $createOtel == true ]; then
echo "1ClickECK.sh: calling 1ClickAWS.sh with otel"
(cd ./aws; bash ./1ClickAWS.sh -b otel $openebs_enabled)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [ $createmode == true ] && [ $k8sonly == true ] && [ $createOtel == false ]; then
echo "1ClickECK.sh: calling 1ClickAWS.sh aks only"
(cd ./aws; bash ./1ClickAWS.sh -b eks $openebs_enabled)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [[ $destroy == true ]]; then
echo "Set kubectl"
(cd ./aws/eks; bash ./setkubectl.sh)
echo "1ClickECK.sh: calling 1ClickAWS.sh destroy"
(cd ./aws; bash ./1ClickAWS.sh -d)
duration=$(( SECONDS - start ))
echo 1ClickECK.sh: Total deployment time in seconds: $duration
elif [[ $destroyeck == true ]]; then
echo "Set kubectl"
(cd ./aws/eks; bash ./setkubectl.sh)
echo "1ClickECK.sh: calling 1ClickAWS.sh destroy ECK"
(cd ./aws; bash ./1ClickAWS.sh -de)
duration=$(( SECONDS - start ))
echo 1ClickECK.sh: Total deployment time in seconds: $duration
elif [[ $destroyOtel == true ]]; then
echo "1ClickECK.sh: Destroying Otel"
(cd ./aws; bash ./1ClickAWS.sh -do)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
else
echo "Please submit a valid argument"
echo "Valid arguments:"
echo " create"
echo " destroy"
fi
elif [[ $cloud == azure ]]; then
(cd azure; python prechecks.py)
if [ $getClusterInfo == true ]; then
echo "Get cluster Info"
(cd ./azure; bash ./getClusterInfo.sh)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [ $getInfraInfo == true ]; then
echo "Get Infra Info"
(cd ./azure/aks; bash ./getClusterInfo.sh)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [ $setKubectl == true ]; then
echo "Set kubectl"
(cd ./azure/aks; bash ./setkubectl.sh)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [ $createmode == true ] && [ $k8sonly == false ] && [ $eckonly == false ]; then
echo "1ClickECK.sh: calling 1ClickAzure.sh with all"
(cd ./azure; bash ./1ClickAzure.sh -b all $openebs_enabled)
duration=$(( SECONDS - start ))
echo 1ClickECK.sh: Total deployment time in seconds: $duration
elif [ $createmode == true ] && [ $k8sonly == true ] && [ $createOtel == true ]; then
echo "1ClickECK.sh: calling 1ClickAzure.sh with otel"
(cd ./azure; bash ./1ClickAzure.sh -b otel $openebs_enabled)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [ $createmode == true ] && [ $k8sonly == true ] && [ $createOtel == false ]; then
echo "1ClickECK.sh: calling 1ClickAzure.sh aks only"
(cd ./azure; bash ./1ClickAzure.sh -b aks $openebs_enabled)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [ $createmode == true ] && [ $k8sonly == false ] && [ $eckonly == true ]; then
echo "1ClickECK.sh: calling 1ClickAzure.sh with eck"
(cd ./azure; bash ./1ClickAzure.sh -b eck $openebs_enabled)
duration=$(( SECONDS - start ))
echo 1ClickECK.sh: Total deployment time in seconds: $duration
elif [[ $destroy == true ]]; then
echo "Set kubectl"
(cd ./azure/aks; bash ./setkubectl.sh)
echo "1ClickECK.sh: calling 1ClickAzure.sh destroy"
(cd ./azure; bash ./1ClickAzure.sh -d )
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [[ $destroyeck == true ]]; then
echo "Set kubectl"
(cd ./azure/aks; bash ./setkubectl.sh)
echo "1ClickECK.sh: calling 1ClickAzure.sh destroy ECK"
(cd ./azure; bash ./1ClickAzure.sh -de)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [[ $destroyOtel == true ]]; then
echo "1ClickECK.sh: Destroying Otel"
(cd ./azure; bash ./1ClickAzure.sh -do)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
else
echo "Please submit a valid argument"
echo "Valid arguments:"
echo " create"
echo " destroy"
fi
elif [[ $cloud == gcp ]]; then
(cd gcp; python prechecks.py)
if [ $getClusterInfo == true ]; then
echo "Get cluster Info"
(cd ./gcp; bash ./getClusterInfo.sh)
duration=$(( SECONDS - start ))
elif [ $getInfraInfo == true ]; then
echo "Get Infra Info"
(cd ./gcp/gke; bash ./getClusterInfo.sh)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [ $setKubectl == true ]; then
echo "Set kubectl"
(cd ./gcp/gke; bash ./setkubectl.sh)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [ $createmode == true ] && [ $k8sonly == true ] && [ $createOtel == true ]; then
echo "1ClickECK.sh: calling 1ClickGCP.sh with otel"
(cd ./gcp; bash ./1ClickGCP.sh -b otel $openebs_enabled)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [ $createmode == true ] && [ $k8sonly == true ] && [ $createOtel == false ]; then
echo "1ClickECK.sh: calling 1ClickGCP.sh gke only"
(cd ./gcp; bash ./1ClickGCP.sh -b gke $openebs_enabled)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [ $createmode == true ] && [ $k8sonly == false ]; then
echo "1ClickECK.sh: calling 1ClickGCP.sh with all"
(cd ./gcp; bash ./1ClickGCP.sh -b all $openebs_enabled)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [[ $destroy == true ]]; then
echo "Set kubectl"
(cd ./gcp/gke; bash ./setkubectl.sh)
echo "1ClickECK.sh: calling 1ClickGCP.sh destroy all"
(cd ./gcp; bash ./1ClickGCP.sh -d)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [[ $destroyeck == true ]]; then
echo "Set kubectl"
(cd ./gcp/gke; bash ./setkubectl.sh)
echo "1ClickECK.sh: calling 1ClickGCP.sh destroy ECK"
(cd ./gcp; bash ./1ClickGCP.sh -de)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [[ $destroyOtel == true ]]; then
echo "1ClickECK.sh: Destroying Otel"
(cd ./gcp; bash ./1ClickGCP.sh -do)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
else
echo "Please submit a valid argument"
echo "Valid arguments:"
echo " create"
echo " destroy"
fi
elif [[ $cloud == ess ]]; then
if [ $getClusterInfo == true ]; then
echo "Get cluster Info"
(cd ./ess; bash ./getClusterInfo.sh)
duration=$(( SECONDS - start ))
elif [ $createmode == true ] ; then
echo "1ClickECK.sh: calling 1ClickESSDeploy.sh"
(cd ./ess; bash ./1ClickESSDeploy.sh)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
elif [[ $destroy == true ]]; then
echo "1ClickECK.sh: calling 1ClickESSDestroy.sh destroy"
(cd ./ess; bash ./1ClickESSDestroy.sh)
duration=$(( SECONDS - start ))
echo "1ClickECK.sh: Total deployment time in seconds:" $duration
else
echo "Please submit a valid argument"
echo "Valid arguments:"
echo " create"
echo " destroy"
fi
else
echo "Not a valid cloud provider. Use: -c aws|azure|gcp"
fi