-
Notifications
You must be signed in to change notification settings - Fork 1
/
egs-uninstall.sh
executable file
·2298 lines (1934 loc) · 109 KB
/
egs-uninstall.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
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# Check if the script is running in Bash
if [ -z "$BASH_VERSION" ]; then
echo "❌ Error: This script must be run in a Bash shell."
echo "Please run the script using: bash script_name.sh"
exit 1
else
echo "✅ Bash shell detected. Version: $BASH_VERSION"
fi
# Function to handle operations that should continue on error
continue_on_error() {
"$@"
if [[ $? -ne 0 ]]; then
echo "❌ Error encountered during execution of: $*"
fi
}
# Print introductory statement
echo "========================================="
echo " EGS UnInstaller Script "
echo "========================================="
echo ""
# Function to show a waiting indicator with a timeout
wait_with_dots() {
local duration=${1:-30}
local message="$2"
echo -n "$message"
trap "exit" INT
for ((i = 0; i < $duration; i++)); do
echo -n "."
sleep 1
done
echo ""
trap - INT
}
prerequisite_check() {
echo "🚀 Starting prerequisite check..."
echo "Checking prerequisites..."
local prerequisites_met=true
# Minimum required versions
local MIN_YQ_VERSION="4.44.2"
local MIN_HELM_VERSION="3.15.0"
local MIN_JQ_VERSION="1.6"
local MIN_KUBECTL_VERSION="1.23.6"
# Check yq
if ! command -v yq &>/dev/null; then
echo -e "\n❌ Error: yq is not installed or not available in PATH."
prerequisites_met=false
else
echo "✔️ yq is installed."
installed_version=$(yq --version | awk '{print $NF}')
if [[ $(echo -e "$MIN_YQ_VERSION\n$installed_version" | sort -V | head -n1) != "$MIN_YQ_VERSION" ]]; then
echo -e "\n❌ Error: yq version $installed_version is below the minimum required version $MIN_YQ_VERSION."
prerequisites_met=false
else
echo "✔️ yq version $installed_version meets or exceeds the requirement."
fi
fi
# Check helm
if ! command -v helm &>/dev/null; then
echo -e "\n❌ Error: helm is not installed or not available in PATH."
prerequisites_met=false
else
echo "✔️ helm is installed."
installed_version=$(helm version --short | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | tr -d 'v')
if [[ $(echo -e "$MIN_HELM_VERSION\n$installed_version" | sort -V | head -n1) != "$MIN_HELM_VERSION" ]]; then
echo -e "\n❌ Error: helm version $installed_version is below the minimum required version $MIN_HELM_VERSION."
prerequisites_met=false
else
echo "✔️ helm version $installed_version meets or exceeds the requirement."
fi
fi
# Check jq
if ! command -v jq &>/dev/null; then
echo -e "\n❌ Error: jq is not installed or not available in PATH."
prerequisites_met=false
else
echo "✔️ jq is installed."
installed_version=$(jq --version | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?')
if [[ $(echo -e "$MIN_JQ_VERSION\n$installed_version" | sort -V | head -n1) != "$MIN_JQ_VERSION" ]]; then
echo -e "\n❌ Error: jq version $installed_version is below the minimum required version $MIN_JQ_VERSION."
prerequisites_met=false
else
echo "✔️ jq version $installed_version meets or exceeds the requirement."
fi
fi
# Check kubectl
if ! command -v kubectl &>/dev/null; then
echo -e "\n❌ Error: kubectl is not installed or not available in PATH."
prerequisites_met=false
else
echo "✔️ kubectl is installed."
installed_version=$(kubectl version --client --output=json | jq -r .clientVersion.gitVersion | tr -d 'v')
if [[ $(echo -e "$MIN_KUBECTL_VERSION\n$installed_version" | sort -V | head -n1) != "$MIN_KUBECTL_VERSION" ]]; then
echo -e "\n❌ Error: kubectl version $installed_version is below the minimum required version $MIN_KUBECTL_VERSION."
prerequisites_met=false
else
echo "✔️ kubectl version $installed_version meets or exceeds the requirement."
fi
fi
if [ "$prerequisites_met" = false ]; then
echo "❌ Please install the missing prerequisites or update to the required versions and try again."
exit 1
fi
echo "✔️ All prerequisites are met."
echo "✔️ Prerequisite check complete."
echo ""
}
# Function to check if a context exists in the kubeconfig
context_exists_in_kubeconfig() {
local kubeconfig="$1"
local kubecontext="$2"
# Print the input values (redirected to stderr)
echo "🔧 context_exists_in_kubeconfig:" >&2
echo " 🗂️ Kubeconfig: $kubeconfig" >&2
echo " 🌐 Kubecontext: $kubecontext" >&2
kubectl config --kubeconfig="$kubeconfig" get-contexts -o name | grep -qw "$kubecontext"
}
# Function to retrieve the API server URL for the provided kubeconfig and context
get_api_server_url() {
local kubeconfig="$1"
local kubecontext="$2"
# Print the input values (redirected to stderr)
echo "🔧 get_api_server_url:" >&2
echo " 🗂️ Kubeconfig: $kubeconfig" >&2
echo " 🌐 Kubecontext: $kubecontext" >&2
kubectl config --kubeconfig="$kubeconfig" view -o jsonpath="{.clusters[?(@.name == \"$(kubectl config --kubeconfig="$kubeconfig" view -o jsonpath="{.contexts[?(@.name == \"$kubecontext\")].context.cluster}")\")].cluster.server}"
}
kubeaccess_precheck() {
local component_name="$1"
local use_global_config="$2"
local global_kubeconfig="$3"
local global_kubecontext="$4"
local component_kubeconfig="$5"
local component_kubecontext="$6"
local verbose="${7:-true}"
local dry_run="${8:-false}"
local kubeaccess_kubeconfig=""
local kubeaccess_context=""
# Treat "null" as an empty value
if [ "$component_kubecontext" = "null" ]; then
component_kubecontext=""
fi
if [ "$component_kubeconfig" = "null" ]; then
component_kubeconfig=""
fi
if [ "$verbose" = "true" ]; then
echo "🚀 Starting precheck for deployment of component: $component_name" >&2
echo "🔧 Initial Variables:" >&2
echo " 🗂️ component_kubeconfig=${component_kubeconfig:-"(not provided)"}" >&2
echo " 🌐 component_kubecontext=${component_kubecontext:-"(not provided)"}" >&2
echo " 🌐 use_global_config=$use_global_config" >&2
echo " 🗂️ global_kubeconfig=$global_kubeconfig" >&2
echo " 🌐 global_kubecontext=$global_kubecontext" >&2
echo "-----------------------------------------" >&2
fi
# Priority is given to component-specific settings
if [ -n "$component_kubeconfig" ] && [ -n "$component_kubecontext" ]; then
if context_exists_in_kubeconfig "$component_kubeconfig" "$component_kubecontext"; then
kubeaccess_kubeconfig="$component_kubeconfig"
kubeaccess_context="$component_kubecontext"
echo "✅ Component level config is used for deployment of $component_name." >&2
api_server_url=$(get_api_server_url "$kubeaccess_kubeconfig" "$kubeaccess_context")
echo "🌐 API Server URL for context '$kubeaccess_context': $api_server_url" >&2
else
echo "❌ Error: Component kubecontext '$component_kubecontext' not found in the specified component kubeconfig." >&2
exit 1
fi
elif [ -z "$component_kubeconfig" ] && [ -n "$component_kubecontext" ]; then
# Use global config with component context
if context_exists_in_kubeconfig "$global_kubeconfig" "$component_kubecontext"; then
kubeaccess_kubeconfig="$global_kubeconfig"
kubeaccess_context="$component_kubecontext"
echo "ℹ️ Component kubeconfig is empty, using global kubeconfig with component context for deployment of $component_name." >&2
api_server_url=$(get_api_server_url "$kubeaccess_kubeconfig" "$kubeaccess_context")
echo "🌐 API Server URL for context '$kubeaccess_context': $api_server_url" >&2
else
echo "❌ Error: Component kubecontext '$component_kubecontext' not found in global kubeconfig." >&2
exit 1
fi
elif [ "$use_global_config" = "true" ]; then
# Fallback to global config and context if component-specific config is not provided
if [ -n "$global_kubeconfig" ] && [ -n "$global_kubecontext" ]; then
if context_exists_in_kubeconfig "$global_kubeconfig" "$global_kubecontext"; then
kubeaccess_kubeconfig="$global_kubeconfig"
kubeaccess_context="$global_kubecontext"
echo "ℹ️ Falling back to global config for deployment of $component_name." >&2
api_server_url=$(get_api_server_url "$kubeaccess_kubeconfig" "$kubeaccess_context")
echo "🌐 API Server URL for context '$kubeaccess_context': $api_server_url" >&2
else
echo "❌ Error: Global kubecontext '$global_kubecontext' not found in the specified global kubeconfig." >&2
exit 1
fi
else
echo "❌ Error: Global kubeconfig or kubecontext is not defined correctly." >&2
exit 1
fi
else
echo "❌ Error: Component and global configurations are either not provided or invalid." >&2
exit 1
fi
if [ "$dry_run" = "false" ]; then
echo "$kubeaccess_kubeconfig $kubeaccess_context"
fi
}
# Function to validate if a given kubecontext is valid
validate_kubecontext() {
local kubeconfig_path=$1
local kubecontext=$2
# Print the input variables (redirected to stderr)
echo "🔧 validate_kubecontext - Input Variables:" >&2
echo " 🗂️ Kubeconfig Path: $kubeconfig_path" >&2
echo " 🌐 Kubecontext: $kubecontext" >&2
# Check if the context exists in the kubeconfig file
if ! kubectl config get-contexts --kubeconfig "$kubeconfig_path" -o name | grep -q "^$kubecontext$"; then
echo "❌ Error: Kubecontext '$kubecontext' does not exist in the kubeconfig file '$kubeconfig_path'." >&2
exit 1
fi
# Try to use the context to connect to the cluster
local cluster_info
cluster_info=$(kubectl cluster-info --kubeconfig "$kubeconfig_path" --context "$kubecontext" 2>&1)
if [[ $? -ne 0 ]]; then
echo "❌ Error: Kubecontext '$kubecontext' is invalid or cannot connect to the cluster." >&2
echo "Details: $cluster_info" >&2
exit 1
fi
# Print the successful validation message (redirected to stderr)
echo "✔️ Kubecontext '$kubecontext' is valid and can connect to the cluster." >&2
# Return success without using echo in stdout
return 0
}
# Kubeslice pre-checks function with context validation
kubeslice_pre_check() {
echo "🚀 Starting Kubeslice pre-checks..."
# Validate access to the kubeslice-controller cluster if installation is not skipped
if [[ "$ENABLE_INSTALL_CONTROLLER" == "true" && "$KUBESLICE_CONTROLLER_SKIP_INSTALLATION" == "false" ]]; then
# Print the input values to kubeaccess_precheck
echo "🔧 Input Values to kubeaccess_precheck:" >&2
echo " 📛 Component Name: kubeslice-controller" >&2
echo " 🌐 Use Global Kubeconfig: $KUBESLICE_CONTROLLER_USE_GLOBAL_KUBECONFIG" >&2
echo " 🗂️ Global Kubeconfig: $GLOBAL_KUBECONFIG" >&2
echo " 🌐 Global Kubecontext: $GLOBAL_KUBECONTEXT" >&2
echo " 🗂️ Component Kubeconfig: $KUBESLICE_CONTROLLER_KUBECONFIG" >&2
echo " 🌐 Component Kubecontext: $KUBESLICE_CONTROLLER_KUBECONTEXT" >&2
echo "-----------------------------------------"
# Using the kubeaccess_precheck function to determine kubeconfig and kubecontext
read -r kubeconfig_path kubecontext < <(kubeaccess_precheck \
"kubeslice-controller" \
"$KUBESLICE_CONTROLLER_USE_GLOBAL_KUBECONFIG" \
"$GLOBAL_KUBECONFIG" \
"$GLOBAL_KUBECONTEXT" \
"$KUBESLICE_CONTROLLER_KUBECONFIG" \
"$KUBESLICE_CONTROLLER_KUBECONTEXT")
# Print the return values with icons
echo "🔧 Return Values from kubeaccess_precheck:" >&2
echo " 🗂️ kubeconfig_path=$kubeconfig_path" >&2
echo " 🌐 kubecontext=$kubecontext" >&2
# Validate the kubecontext if both kubeconfig_path and kubecontext are set and not null
if [[ -n "$kubeconfig_path" && "$kubeconfig_path" != "null" && -n "$kubecontext" && "$kubecontext" != "null" ]]; then
echo "🔍 Validating Kubecontext:" >&2
echo " 🗂️ Kubeconfig Path: $kubeconfig_path" >&2
echo " 🌐 Kubecontext: $kubecontext" >&2
validate_kubecontext "$kubeconfig_path" "$kubecontext"
else
echo "⚠️ Warning: Either kubeconfig_path or kubecontext is not set or is null." >&2
echo " 🗂️ Kubeconfig Path: $kubeconfig_path" >&2
echo " 🌐 Kubecontext: $kubecontext" >&2
exit 1
fi
# Prepare the context argument if the context is available
local context_arg=""
if [[ -n "$kubecontext" && "$kubecontext" != "null" ]]; then
context_arg="--context $kubecontext"
fi
echo "-----------------------------------------" >&2
echo "🔍 Validating access to the kubeslice-controller cluster using kubeconfig '$kubeconfig_path'..." >&2
echo "🔧 Variables:" >&2
echo " ENABLE_INSTALL_CONTROLLER=$ENABLE_INSTALL_CONTROLLER" >&2
echo " KUBESLICE_CONTROLLER_SKIP_INSTALLATION=$KUBESLICE_CONTROLLER_SKIP_INSTALLATION" >&2
echo " kubeconfig_path=$kubeconfig_path" >&2
echo " kubecontext=$kubecontext" >&2
echo " KUBESLICE_CONTROLLER_USE_GLOBAL_KUBECONFIG=$KUBESLICE_CONTROLLER_USE_GLOBAL_KUBECONFIG" >&2
echo " GLOBAL_KUBECONFIG=$GLOBAL_KUBECONFIG" >&2
echo " GLOBAL_KUBECONTEXT=$GLOBAL_KUBECONTEXT" >&2
echo " context_arg=$context_arg" >&2
echo "-----------------------------------------" >&2
cluster_info=$(kubectl cluster-info --kubeconfig "$kubeconfig_path" $context_arg 2>&1)
if [[ $? -ne 0 ]]; then
echo "❌ Error: Unable to access the kubeslice-controller cluster using kubeconfig '$kubeconfig_path'." >&2
echo "Details: $cluster_info" >&2
exit 1
fi
controller_cluster_endpoint=$(get_api_server_url "$kubeconfig_path" "$kubecontext")
echo "✔️ Successfully accessed kubeslice-controller cluster. Kubernetes endpoint: $controller_cluster_endpoint" >&2
echo "-----------------------------------------" >&2
else
echo "⏩ Skipping kubeslice-controller cluster validation as installation is skipped or not enabled." >&2
fi
# Validate access to the kubeslice-ui cluster if installation is not skipped
if [[ "$ENABLE_INSTALL_UI" == "true" && "$KUBESLICE_UI_SKIP_INSTALLATION" == "false" ]]; then
# Print the input variables
echo "🔧 kubeaccess_precheck - Input Variables:" >&2
echo " 📛 Component Name: kubeslice-ui" >&2
echo " 🌐 Use Global Kubeconfig: $KUBESLICE_UI_USE_GLOBAL_KUBECONFIG" >&2
echo " 🗂️ Global Kubeconfig: $GLOBAL_KUBECONFIG" >&2
echo " 🌐 Global Kubecontext: $GLOBAL_KUBECONTEXT" >&2
echo " 🗂️ Component Kubeconfig: $KUBESLICE_UI_KUBECONFIG" >&2
echo " 🌐 Component Kubecontext: $KUBESLICE_UI_KUBECONTEXT" >&2
echo "-----------------------------------------"
# Using the kubeaccess_precheck function to determine kubeconfig and kubecontext
read -r kubeconfig_path kubecontext < <(kubeaccess_precheck \
"kubeslice-ui" \
"$KUBESLICE_UI_USE_GLOBAL_KUBECONFIG" \
"$GLOBAL_KUBECONFIG" \
"$GLOBAL_KUBECONTEXT" \
"$KUBESLICE_UI_KUBECONFIG" \
"$KUBESLICE_UI_KUBECONTEXT")
# Print the output variables
echo "🔧 kubeaccess_precheck - Output Variables:" >&2
echo " 🗂️ Kubeconfig Path: $kubeconfig_path" >&2
echo " 🌐 Kubecontext: $kubecontext" >&2
echo "-----------------------------------------"
# Validate the kubecontext if both kubeconfig_path and kubecontext are set and not null
if [[ -n "$kubeconfig_path" && "$kubeconfig_path" != "null" && -n "$kubecontext" && "$kubecontext" != "null" ]]; then
echo "🔍 Validating Kubecontext:" >&2
echo " 🗂️ Kubeconfig Path: $kubeconfig_path" >&2
echo " 🌐 Kubecontext: $kubecontext" >&2
validate_kubecontext "$kubeconfig_path" "$kubecontext"
else
echo "⚠️ Warning: Either kubeconfig_path or kubecontext is not set or is null." >&2
echo " 🗂️ Kubeconfig Path: $kubeconfig_path" >&2
echo " 🌐 Kubecontext: $kubecontext" >&2
exit 1
fi
# Prepare the context argument if the context is available
local context_arg=""
if [[ -n "$kubecontext" && "$kubecontext" != "null" ]]; then
context_arg="--context $kubecontext"
fi
echo "-----------------------------------------" >&2
echo "🔍 Validating access to the kubeslice-ui cluster using kubeconfig '$kubeconfig_path'..." >&2
echo "🔧 Variables:" >&2
echo " ENABLE_INSTALL_UI=$ENABLE_INSTALL_UI" >&2
echo " KUBESLICE_UI_SKIP_INSTALLATION=$KUBESLICE_UI_SKIP_INSTALLATION" >&2
echo " kubeconfig_path=$kubeconfig_path" >&2
echo " kubecontext=$kubecontext" >&2
echo " KUBESLICE_UI_USE_GLOBAL_KUBECONFIG=$KUBESLICE_UI_USE_GLOBAL_KUBECONFIG" >&2
echo " GLOBAL_KUBECONFIG=$GLOBAL_KUBECONFIG" >&2
echo " GLOBAL_KUBECONTEXT=$GLOBAL_KUBECONTEXT" >&2
echo "-----------------------------------------" >&2
cluster_info=$(kubectl cluster-info --kubeconfig "$kubeconfig_path" $context_arg 2>&1)
if [[ $? -ne 0 ]]; then
echo "❌ Error: Unable to access the kubeslice-ui cluster using kubeconfig '$kubeconfig_path'." >&2
echo "Details: $cluster_info"
exit 1
fi
ui_cluster_endpoint=$(get_api_server_url "$kubeconfig_path" "$kubecontext")
echo "✔️ Successfully accessed kubeslice-ui cluster. Kubernetes endpoint: $ui_cluster_endpoint" >&2
echo "-----------------------------------------" >&2
else
echo "⏩ Skipping kubeslice-ui cluster validation as installation is skipped or not enabled." >&2
fi
# Iterate through each worker configuration and validate access if installation is not skipped
for worker in "${KUBESLICE_WORKERS[@]}"; do
IFS="|" read -r worker_name skip_installation use_global_kubeconfig kubeconfig kubecontext namespace release_name chart_name repo_url username password values_file inline_values image_pull_secret_repo image_pull_secret_username image_pull_secret_password image_pull_secret_email helm_flags verify_install verify_install_timeout skip_on_verify_fail <<<"$worker"
if [[ "$skip_installation" == "false" ]]; then
# Print the input variables for the kubeaccess_precheck function
echo "🔧 Input Variables for kubeaccess_precheck:" >&2
echo " 📛 Component Name: $worker_name" >&2
echo " 🌐 Use Global Kubeconfig: $use_global_kubeconfig" >&2
echo " 🗂️ Global Kubeconfig: $GLOBAL_KUBECONFIG" >&2
echo " 🌐 Global Kubecontext: $GLOBAL_KUBECONTEXT" >&2
echo " 🗂️ Component Kubeconfig: $kubeconfig" >&2
echo " 🌐 Component Kubecontext: $kubecontext" >&2
echo "-----------------------------------------" >&2
# Print input variables before calling kubeaccess_precheck
echo "🔧 kubeaccess_precheck - Input Variables:" >&2
echo " 📛 Worker Name: $worker_name" >&2
echo " 🌐 Use Global Kubeconfig: $use_global_kubeconfig" >&2
echo " 🗂️ Global Kubeconfig: $GLOBAL_KUBECONFIG" >&2
echo " 🌐 Global Kubecontext: $GLOBAL_KUBECONTEXT" >&2
echo " 🗂️ Component Kubeconfig: $kubeconfig" >&2
echo " 🌐 Component Kubecontext: $kubecontext" >&2
echo "-----------------------------------------" >&2
# Call the kubeaccess_precheck function and capture output
read -r kubeconfig_path kubecontext < <(kubeaccess_precheck \
"$worker_name" \
"$use_global_kubeconfig" \
"$GLOBAL_KUBECONFIG" \
"$GLOBAL_KUBECONTEXT" \
"$kubeconfig" \
"$kubecontext")
# Print output variables after calling kubeaccess_precheck
echo "🔧 kubeaccess_precheck - Output Variables:" >&2
echo " 🗂️ Kubeconfig Path: $kubeconfig_path" >&2
echo " 🌐 Kubecontext: $kubecontext" >&2
echo "-----------------------------------------" >&2
# Validate the kubecontext if both kubeconfig_path and kubecontext are set and not null
if [[ -n "$kubeconfig_path" && "$kubeconfig_path" != "null" && -n "$kubecontext" && "$kubecontext" != "null" ]]; then
echo "🔍 Validating Kubecontext:" >&2
echo " 🗂️ Kubeconfig Path: $kubeconfig_path" >&2
echo " 🌐 Kubecontext: $kubecontext" >&2
validate_kubecontext "$kubeconfig_path" "$kubecontext"
else
echo "⚠️ Warning: Either kubeconfig_path or kubecontext is not set or is null." >&2
echo " 🗂️ Kubeconfig Path: $kubeconfig_path" >&2
echo " 🌐 Kubecontext: $kubecontext" >&2
exit 1
fi
# Prepare the context argument if the context is available
local context_arg=""
if [[ -n "$kubecontext" && "$kubecontext" != "null" ]]; then
context_arg="--context $kubecontext"
fi
echo "-----------------------------------------" >&2
echo "🔍 Validating access to the worker cluster '$worker_name' using kubeconfig '$kubeconfig_path'..." >&2
echo "🔧 Variables:" >&2
echo " worker_name=$worker_name" >&2
echo " skip_installation=$skip_installation" >&2
echo " use_global_kubeconfig=$use_global_kubeconfig" >&2
echo " kubeconfig=$kubeconfig_path" >&2
echo " kubecontext=$kubecontext" >&2
echo " context_arg=$context_arg" >&2
echo " namespace=$namespace" >&2
echo " release_name=$release_name" >&2
echo " chart_name=$chart_name" >&2
echo " repo_url=$repo_url" >&2
echo " username=$username" >&2
echo " password=$password" >&2
echo "-----------------------------------------" >&2
cluster_info=$(kubectl cluster-info --kubeconfig "$kubeconfig_path" $context_arg 2>&1)
if [[ $? -ne 0 ]]; then
echo "❌ Error: Unable to access the worker cluster '$worker_name' using kubeconfig '$kubeconfig_path'." >&2
echo "Details: $cluster_info" >&2
exit 1
fi
worker_cluster_endpoint=$(get_api_server_url "$kubeconfig_path" "$kubecontext")
echo "✔️ Successfully accessed worker cluster '$worker_name'. Kubernetes endpoint: $worker_cluster_endpoint" >&2
# Check for nodes labeled with 'kubeslice.io/node-type=gateway'
echo "🔍 Checking for nodes labeled 'kubeslice.io/node-type=gateway' in worker cluster '$worker_name'..." >&2
gateway_nodes=$(kubectl get nodes --kubeconfig $kubeconfig_path $context_arg -l kubeslice.io/node-type=gateway --no-headers -o custom-columns=NAME:.metadata.name)
if [ -z "$gateway_nodes" ]; then
echo "✔️ No nodes labeled with 'kubeslice.io/node-type=gateway' found." >&2
else
echo "🔧 Removing label 'kubeslice.io/node-type=gateway' from nodes in worker cluster '$worker_name'..." >&2
for node in $gateway_nodes; do
kubectl label node "$node" kubeslice.io/node-type- --kubeconfig $kubeconfig_path $context_arg --overwrite
echo "✔️ Label removed from node '$node'." >&2
done
echo "✔️ All gateway labels removed successfully." >&2
fi
echo "-----------------------------------------" >&2
else
echo "⏩ Skipping validation for worker cluster '$worker_name' as installation is skipped." >&2
fi
done
echo "✔️ Kubeslice pre-checks completed successfully." >&2
echo ""
}
validate_paths() {
echo "🚀 Validating paths..." >&2
local error_found=false
# Check BASE_PATH
if [ ! -d "$BASE_PATH" ]; then
echo "❌ Error: BASE_PATH '$BASE_PATH' does not exist or is not a directory."
error_found=true
fi
# Check GLOBAL_KUBECONFIG
if [ ! -f "$GLOBAL_KUBECONFIG" ]; then
echo "⚠️ GLOBAL_KUBECONFIG '$GLOBAL_KUBECONFIG' does not exist or is not a file."
fi
# Check GLOBAL_KUBECONTEXT
if [ ! -f "$GLOBAL_KUBECONTEXT" ]; then
echo "⚠️ GLOBAL_KUBECONTEXT '$GLOBAL_KUBECONTEXT' does not exist or is not a file."
fi
# Check KUBESLICE_CONTROLLER_KUBECONFIG if controller installation is enabled and global config is not being used
if [ "$ENABLE_INSTALL_CONTROLLER" = "true" ] && [ "$KUBESLICE_CONTROLLER_USE_GLOBAL_KUBECONFIG" != "true" ]; then
if [ -z "$KUBESLICE_CONTROLLER_KUBECONFIG" ] || [ "$KUBESLICE_CONTROLLER_KUBECONFIG" = "null" ] || [ ! -f "$KUBESLICE_CONTROLLER_KUBECONFIG" ]; then
echo "❌ Error: KUBESLICE_CONTROLLER_KUBECONFIG '$KUBESLICE_CONTROLLER_KUBECONFIG' does not exist or is not a file."
error_found=true
fi
if [ -z "$KUBESLICE_CONTROLLER_KUBECONTEXT" ] || [ "$KUBESLICE_CONTROLLER_KUBECONTEXT" = "null" ]; then
echo "❌ Error: KUBESLICE_CONTROLLER_KUBECONTEXT is not defined."
error_found=true
fi
fi
# Check KUBESLICE_UI_KUBECONFIG if UI installation is enabled and global config is not being used
if [ "$ENABLE_INSTALL_UI" = "true" ] && [ "$KUBESLICE_UI_USE_GLOBAL_KUBECONFIG" != "true" ]; then
if [ -z "$KUBESLICE_UI_KUBECONFIG" ] || [ "$KUBESLICE_UI_KUBECONFIG" = "null" ] || [ ! -f "$KUBESLICE_UI_KUBECONFIG" ]; then
echo "❌ Error: KUBESLICE_UI_KUBECONFIG '$KUBESLICE_UI_KUBECONFIG' does not exist or is not a file."
error_found=true
fi
if [ -z "$KUBESLICE_UI_KUBECONTEXT" ] || [ "$KUBESLICE_UI_KUBECONTEXT" = "null" ]; then
echo "❌ Error: KUBESLICE_UI_KUBECONTEXT is not defined."
error_found=true
fi
fi
# Check LOCAL_CHARTS_PATH if local charts are used
if [ "$USE_LOCAL_CHARTS" = "true" ]; then
if [ ! -d "$LOCAL_CHARTS_PATH" ]; then
echo "❌ Error: LOCAL_CHARTS_PATH '$LOCAL_CHARTS_PATH' does not exist or is not a directory."
error_found=true
fi
fi
# Check if the manifests path exists and is valid if specified
if [ -n "$MANIFESTS_PATH" ]; then
if [ ! -d "$MANIFESTS_PATH" ]; then
echo "❌ Error: MANIFESTS_PATH '$MANIFESTS_PATH' does not exist or is not a directory."
error_found=true
fi
fi
# Check kubeconfigs for manifests if MANIFESTS_PATH is specified
if [ -n "$MANIFESTS_PATH" ]; then
for manifest in "$MANIFESTS_PATH"/*.yaml; do
if [ ! -f "$manifest" ]; then
echo "❌ Error: Manifest '$manifest' does not exist or is not a file."
error_found=true
fi
done
fi
# If any errors were found, exit the script
if [ "$error_found" = "true" ]; then
echo "❌ One or more critical errors were found in the paths or required commands. Please correct them and try again."
exit 1
else
echo "✔️ All required paths and commands are valid."
fi
}
# Function to parse YAML using yq
parse_yaml() {
local yaml_file=$1
echo "🚀 Parsing input YAML file '$yaml_file'..."
wait_with_dots 5 " "
# Extract BASE_PATH
BASE_PATH=$(yq e '.base_path' "$yaml_file")
if [ -z "$BASE_PATH" ] || [ "$BASE_PATH" = "null" ]; then
echo "⚠️ BASE_PATH not specified. Defaulting to script directory."
BASE_PATH=$(dirname "$(realpath "$0")") # Default to the script's directory
fi
# Ensure BASE_PATH is absolute
BASE_PATH=$(realpath "$BASE_PATH")
# Create installation-files directory if not exists
INSTALLATION_FILES_PATH="$BASE_PATH/installation-files"
mkdir -p "$INSTALLATION_FILES_PATH"
# Extract precheck flag
PRECHECK=$(yq e '.precheck' "$yaml_file")
if [ -z "$PRECHECK" ] || [ "$PRECHECK" = "null" ]; then
PRECHECK="true" # Default to true if not specified
fi
# Extract Kubeslice pre-check flag
KUBESLICE_PRECHECK=$(yq e '.kubeslice_precheck' "$yaml_file")
if [ -z "$KUBESLICE_PRECHECK" ] || [ "$KUBESLICE_PRECHECK" = "null" ]; then
KUBESLICE_PRECHECK="false" # Default to false if not specified
fi
# Extract the add_node_label setting
ADD_NODE_LABEL=$(yq e '.add_node_label' "$yaml_file")
if [ -z "$ADD_NODE_LABEL" ] || [ "$ADD_NODE_LABEL" = "null" ]; then
ADD_NODE_LABEL="false" # Default to false if not specified
fi
# Extract cloud_install configuration
CLOUD_INSTALL=$(yq e '.cloud_install' "$yaml_file")
if [ -z "$CLOUD_INSTALL" ] || [ "$CLOUD_INSTALL" = "null" ]; then
# echo "⚠️ CLOUD_INSTALL not specified. Skipping cloud-specific installations."
CLOUD_INSTALL=""
fi
# Extract global Helm repo settings
GLOBAL_HELM_REPO_URL=$(yq e '.global_helm_repo_url' "$yaml_file")
GLOBAL_HELM_USERNAME=$(yq e '.global_helm_username' "$yaml_file")
GLOBAL_HELM_PASSWORD=$(yq e '.global_helm_password' "$yaml_file")
READD_HELM_REPOS=$(yq e '.readd_helm_repos' "$yaml_file")
# Extract global imagePullSecrets settings
GLOBAL_IMAGE_PULL_SECRET_REPO=$(yq e '.global_image_pull_secret.repository' "$yaml_file")
GLOBAL_IMAGE_PULL_SECRET_USERNAME=$(yq e '.global_image_pull_secret.username' "$yaml_file")
GLOBAL_IMAGE_PULL_SECRET_PASSWORD=$(yq e '.global_image_pull_secret.password' "$yaml_file")
GLOBAL_IMAGE_PULL_SECRET_EMAIL=$(yq e '.global_image_pull_secret.email' "$yaml_file")
# Verify install settings
GLOBAL_VERIFY_INSTALL=$(yq e '.verify_install' "$yaml_file")
if [ -z "$GLOBAL_VERIFY_INSTALL" ] || [ "$GLOBAL_VERIFY_INSTALL" = "null" ]; then
GLOBAL_VERIFY_INSTALL="true" # Default to true if not specified
fi
GLOBAL_VERIFY_INSTALL_TIMEOUT=$(yq e '.verify_install_timeout' "$yaml_file")
if [ -z "$GLOBAL_VERIFY_INSTALL_TIMEOUT" ] || [ "$GLOBAL_VERIFY_INSTALL_TIMEOUT" = "null" ]; then
GLOBAL_VERIFY_INSTALL_TIMEOUT="600" # Default to 10 minutes if not specified
fi
GLOBAL_SKIP_ON_VERIFY_FAIL=$(yq e '.skip_on_verify_fail' "$yaml_file")
if [ -z "$GLOBAL_SKIP_ON_VERIFY_FAIL" ] || [ "$GLOBAL_SKIP_ON_VERIFY_FAIL" = "null" ]; then
GLOBAL_SKIP_ON_VERIFY_FAIL="false" # Default to error out if not specified
fi
# Extract the list of required binaries
REQUIRED_BINARIES=($(yq e '.required_binaries[]' "$yaml_file"))
if [ ${#REQUIRED_BINARIES[@]} -eq 0 ]; then
REQUIRED_BINARIES=("yq" "helm" "kubectl" "kubectx") # Default list if none specified
fi
# Extract global settings with defaults
GLOBAL_KUBECONFIG=$(yq e '.global_kubeconfig' "$yaml_file")
if [ -z "$GLOBAL_KUBECONFIG" ] || [ "$GLOBAL_KUBECONFIG" = "null" ]; then
echo -e "\n❌ Error: global_kubeconfig is not specified in the YAML file."
exit 1
fi
GLOBAL_KUBECONFIG="$BASE_PATH/$GLOBAL_KUBECONFIG"
GLOBAL_KUBECONTEXT=$(yq e '.global_kubecontext' "$yaml_file")
if [ -z "$GLOBAL_KUBECONTEXT" ] || [ "$GLOBAL_KUBECONTEXT" = "null" ]; then
echo -e "\n❌ Error: global_kubecontext is not specified in the YAML file."
exit 1
fi
USE_LOCAL_CHARTS=$(yq e '.use_local_charts' "$yaml_file")
if [ -z "$USE_LOCAL_CHARTS" ] || [ "$USE_LOCAL_CHARTS" = "null" ]; then
USE_LOCAL_CHARTS="false"
fi
LOCAL_CHARTS_PATH=$(yq e '.local_charts_path' "$yaml_file")
if [ -z "$LOCAL_CHARTS_PATH" ] || [ "$LOCAL_CHARTS_PATH" = "null" ]; then
LOCAL_CHARTS_PATH="./charts"
fi
LOCAL_CHARTS_PATH="$BASE_PATH/$LOCAL_CHARTS_PATH"
# Extract global context usage flag
USE_GLOBAL_CONTEXT=$(yq e '.use_global_context' "$yaml_file")
if [ -z "$USE_GLOBAL_CONTEXT" ] || [ "$USE_GLOBAL_CONTEXT" = "null" ]; then
USE_GLOBAL_CONTEXT="true" # Default to true if not specified
fi
echo "DEBUG: BASE_PATH=$BASE_PATH"
echo "DEBUG: LOCAL_CHARTS_PATH=$LOCAL_CHARTS_PATH"
# Global enable/disable flags for different stages
ENABLE_FETCH_CONTROLLER_SECRETS=$(yq e '.enable_fetch_controller_secrets' "$yaml_file")
if [ -z "$ENABLE_FETCH_CONTROLLER_SECRETS" ] || [ "$ENABLE_FETCH_CONTROLLER_SECRETS" = "null" ]; then
ENABLE_FETCH_CONTROLLER_SECRETS="true"
fi
ENABLE_PREPARE_WORKER_VALUES_FILE=$(yq e '.enable_prepare_worker_values_file' "$yaml_file")
if [ -z "$ENABLE_PREPARE_WORKER_VALUES_FILE" ] || [ "$ENABLE_PREPARE_WORKER_VALUES_FILE" = "null" ]; then
ENABLE_PREPARE_WORKER_VALUES_FILE="true"
fi
ENABLE_INSTALL_CONTROLLER=$(yq e '.enable_install_controller' "$yaml_file")
if [ -z "$ENABLE_INSTALL_CONTROLLER" ] || [ "$ENABLE_INSTALL_CONTROLLER" = "null" ]; then
ENABLE_INSTALL_CONTROLLER="true"
fi
ENABLE_INSTALL_UI=$(yq e '.enable_install_ui' "$yaml_file")
if [ -z "$ENABLE_INSTALL_UI" ] || [ "$ENABLE_INSTALL_UI" = "null" ]; then
ENABLE_INSTALL_UI="true"
fi
ENABLE_INSTALL_WORKER=$(yq e '.enable_install_worker' "$yaml_file")
if [ -z "$ENABLE_INSTALL_WORKER" ] || [ "$ENABLE_INSTALL_WORKER" = "null" ]; then
ENABLE_INSTALL_WORKER="true"
fi
# Extract values for kubeslice-controller-egs
KUBESLICE_CONTROLLER_SKIP_INSTALLATION=$(yq e '.kubeslice_controller_egs.skip_installation' "$yaml_file")
if [ -z "$KUBESLICE_CONTROLLER_SKIP_INSTALLATION" ] || [ "$KUBESLICE_CONTROLLER_SKIP_INSTALLATION" = "null" ]; then
KUBESLICE_CONTROLLER_SKIP_INSTALLATION="false"
fi
KUBESLICE_CONTROLLER_USE_GLOBAL_KUBECONFIG=$(yq e '.kubeslice_controller_egs.use_global_kubeconfig' "$yaml_file")
if [ -z "$KUBESLICE_CONTROLLER_USE_GLOBAL_KUBECONFIG" ] || [ "$KUBESLICE_CONTROLLER_USE_GLOBAL_KUBECONFIG" = "null" ]; then
KUBESLICE_CONTROLLER_USE_GLOBAL_KUBECONFIG="true"
fi
KUBESLICE_CONTROLLER_KUBECONFIG=$(yq e '.kubeslice_controller_egs.kubeconfig' "$yaml_file")
KUBESLICE_CONTROLLER_KUBECONFIG="${KUBESLICE_CONTROLLER_KUBECONFIG:-$GLOBAL_KUBECONFIG}"
KUBESLICE_CONTROLLER_KUBECONTEXT=$(yq e '.kubeslice_controller_egs.kubecontext' "$yaml_file")
if [ -z "$KUBESLICE_CONTROLLER_KUBECONTEXT" ] || [ "$KUBESLICE_CONTROLLER_KUBECONTEXT" = "null" ]; then
KUBESLICE_CONTROLLER_KUBECONTEXT="$GLOBAL_KUBECONTEXT"
fi
KUBESLICE_CONTROLLER_NAMESPACE=$(yq e '.kubeslice_controller_egs.namespace' "$yaml_file")
if [ -z "$KUBESLICE_CONTROLLER_NAMESPACE" ] || [ "$KUBESLICE_CONTROLLER_NAMESPACE" = "null" ]; then
KUBESLICE_CONTROLLER_NAMESPACE="kubeslice-controller"
fi
KUBESLICE_CONTROLLER_RELEASE_NAME=$(yq e '.kubeslice_controller_egs.release' "$yaml_file")
if [ -z "$KUBESLICE_CONTROLLER_RELEASE_NAME" ] || [ "$KUBESLICE_CONTROLLER_RELEASE_NAME" = "null" ]; then
KUBESLICE_CONTROLLER_RELEASE_NAME="$KUBESLICE_CONTROLLER_NAMESPACE-release"
fi
KUBESLICE_CONTROLLER_CHART_NAME=$(yq e '.kubeslice_controller_egs.chart' "$yaml_file")
if [ -z "$KUBESLICE_CONTROLLER_CHART_NAME" ] || [ "$KUBESLICE_CONTROLLER_CHART_NAME" = "null" ]; then
KUBESLICE_CONTROLLER_CHART_NAME="kubeslice-controller"
fi
KUBESLICE_CONTROLLER_REPO_URL=$(yq e '.kubeslice_controller_egs.repo_url' "$yaml_file")
if [ -z "$KUBESLICE_CONTROLLER_REPO_URL" ] || [ "$KUBESLICE_CONTROLLER_REPO_URL" = "null" ]; then
KUBESLICE_CONTROLLER_REPO_URL="$GLOBAL_HELM_REPO_URL"
fi
KUBESLICE_CONTROLLER_USERNAME=$(yq e '.kubeslice_controller_egs.username' "$yaml_file")
if [ -z "$KUBESLICE_CONTROLLER_USERNAME" ] || [ "$KUBESLICE_CONTROLLER_USERNAME" = "null" ]; then
KUBESLICE_CONTROLLER_USERNAME="$GLOBAL_HELM_USERNAME"
fi
KUBESLICE_CONTROLLER_PASSWORD=$(yq e '.kubeslice_controller_egs.password' "$yaml_file")
if [ -z "$KUBESLICE_CONTROLLER_PASSWORD" ] || [ "$KUBESLICE_CONTROLLER_PASSWORD" = "null" ]; then
KUBESLICE_CONTROLLER_PASSWORD="$GLOBAL_HELM_PASSWORD"
fi
KUBESLICE_CONTROLLER_VALUES_FILE=$(yq e '.kubeslice_controller_egs.values_file' "$yaml_file")
KUBESLICE_CONTROLLER_VALUES_FILE="$BASE_PATH/$KUBESLICE_CONTROLLER_VALUES_FILE"
KUBESLICE_CONTROLLER_INLINE_VALUES=$(yq e '.kubeslice_controller_egs.inline_values // {}' "$yaml_file")
KUBESLICE_CONTROLLER_IMAGE_PULL_SECRET_REPO=$(yq e '.kubeslice_controller_egs.imagePullSecrets.repository' "$yaml_file")
if [ -z "$KUBESLICE_CONTROLLER_IMAGE_PULL_SECRET_REPO" ] || [ "$KUBESLICE_CONTROLLER_IMAGE_PULL_SECRET_REPO" = "null" ]; then
KUBESLICE_CONTROLLER_IMAGE_PULL_SECRET_REPO="$GLOBAL_IMAGE_PULL_SECRET_REPO"
fi
KUBESLICE_CONTROLLER_IMAGE_PULL_SECRET_USERNAME=$(yq e '.kubeslice_controller_egs.imagePullSecrets.username' "$yaml_file")
if [ -z "$KUBESLICE_CONTROLLER_IMAGE_PULL_SECRET_USERNAME" ] || [ "$KUBESLICE_CONTROLLER_IMAGE_PULL_SECRET_USERNAME" = "null" ]; then
KUBESLICE_CONTROLLER_IMAGE_PULL_SECRET_USERNAME="$GLOBAL_IMAGE_PULL_SECRET_USERNAME"
fi
KUBESLICE_CONTROLLER_IMAGE_PULL_SECRET_PASSWORD=$(yq e '.kubeslice_controller_egs.imagePullSecrets.password' "$yaml_file")
if [ -z "$KUBESLICE_CONTROLLER_IMAGE_PULL_SECRET_PASSWORD" ] || [ "$KUBESLICE_CONTROLLER_IMAGE_PULL_SECRET_PASSWORD" = "null" ]; then
KUBESLICE_CONTROLLER_IMAGE_PULL_SECRET_PASSWORD="$GLOBAL_IMAGE_PULL_SECRET_PASSWORD"
fi
KUBESLICE_CONTROLLER_IMAGE_PULL_SECRET_EMAIL=$(yq e '.kubeslice_controller_egs.imagePullSecrets.email' "$yaml_file")
if [ -z "$KUBESLICE_CONTROLLER_IMAGE_PULL_SECRET_EMAIL" ] || [ "$KUBESLICE_CONTROLLER_IMAGE_PULL_SECRET_EMAIL" = "null" ]; then
KUBESLICE_CONTROLLER_IMAGE_PULL_SECRET_EMAIL="$GLOBAL_IMAGE_PULL_SECRET_EMAIL"
fi
KUBESLICE_CONTROLLER_HELM_FLAGS=$(yq e '.kubeslice_controller_egs.helm_flags' "$yaml_file")
KUBESLICE_CONTROLLER_VERIFY_INSTALL=$(yq e '.kubeslice_controller_egs.verify_install' "$yaml_file")
if [ -z "$KUBESLICE_CONTROLLER_VERIFY_INSTALL" ] || [ "$KUBESLICE_CONTROLLER_VERIFY_INSTALL" = "null" ]; then
KUBESLICE_CONTROLLER_VERIFY_INSTALL="$GLOBAL_VERIFY_INSTALL"
fi
KUBESLICE_CONTROLLER_VERIFY_INSTALL_TIMEOUT=$(yq e '.kubeslice_controller_egs.verify_install_timeout' "$yaml_file")
if [ -z "$KUBESLICE_CONTROLLER_VERIFY_INSTALL_TIMEOUT" ] || [ "$KUBESLICE_CONTROLLER_VERIFY_INSTALL_TIMEOUT" = "null" ]; then
KUBESLICE_CONTROLLER_VERIFY_INSTALL_TIMEOUT="$GLOBAL_VERIFY_INSTALL_TIMEOUT"
fi
KUBESLICE_CONTROLLER_SKIP_ON_VERIFY_FAIL=$(yq e '.kubeslice_controller_egs.skip_on_verify_fail' "$yaml_file")
if [ -z "$KUBESLICE_CONTROLLER_SKIP_ON_VERIFY_FAIL" ] || [ "$KUBESLICE_CONTROLLER_SKIP_ON_VERIFY_FAIL" = "null" ]; then
KUBESLICE_CONTROLLER_SKIP_ON_VERIFY_FAIL="$GLOBAL_SKIP_ON_VERIFY_FAIL"
fi
# Extract values for kubeslice-ui-egs
KUBESLICE_UI_SKIP_INSTALLATION=$(yq e '.kubeslice_ui_egs.skip_installation' "$yaml_file")
if [ -z "$KUBESLICE_UI_SKIP_INSTALLATION" ] || [ "$KUBESLICE_UI_SKIP_INSTALLATION" = "null" ]; then
KUBESLICE_UI_SKIP_INSTALLATION="false"
fi
KUBESLICE_UI_USE_GLOBAL_KUBECONFIG=$(yq e '.kubeslice_ui_egs.use_global_kubeconfig' "$yaml_file")
if [ -z "$KUBESLICE_UI_USE_GLOBAL_KUBECONFIG" ] || [ "$KUBESLICE_UI_USE_GLOBAL_KUBECONFIG" = "null" ]; then
KUBESLICE_UI_USE_GLOBAL_KUBECONFIG="true"
fi
KUBESLICE_UI_KUBECONFIG=$(yq e '.kubeslice_ui_egs.kubeconfig' "$yaml_file")
KUBESLICE_UI_KUBECONFIG="${KUBESLICE_UI_KUBECONFIG:-$GLOBAL_KUBECONFIG}"
KUBESLICE_UI_KUBECONTEXT=$(yq e '.kubeslice_ui_egs.kubecontext' "$yaml_file")
if [ -z "$KUBESLICE_UI_KUBECONTEXT" ] || [ "$KUBESLICE_UI_KUBECONTEXT" = "null" ]; then
KUBESLICE_UI_KUBECONTEXT="$GLOBAL_KUBECONTEXT"
fi
KUBESLICE_UI_NAMESPACE=$(yq e '.kubeslice_ui_egs.namespace' "$yaml_file")
if [ -z "$KUBESLICE_UI_NAMESPACE" ] || [ "$KUBESLICE_UI_NAMESPACE" = "null" ]; then
KUBESLICE_UI_NAMESPACE="kubeslice-ui"
fi
KUBESLICE_UI_RELEASE_NAME=$(yq e '.kubeslice_ui_egs.release' "$yaml_file")
if [ -z "$KUBESLICE_UI_RELEASE_NAME" ] || [ "$KUBESLICE_UI_RELEASE_NAME" = "null" ]; then
KUBESLICE_UI_RELEASE_NAME="$KUBESLICE_UI_NAMESPACE-release"
fi
KUBESLICE_UI_CHART_NAME=$(yq e '.kubeslice_ui_egs.chart' "$yaml_file")
if [ -z "$KUBESLICE_UI_CHART_NAME" ] || [ "$KUBESLICE_UI_CHART_NAME" = "null" ]; then
KUBESLICE_UI_CHART_NAME="kubeslice-ui"
fi
KUBESLICE_UI_REPO_URL=$(yq e '.kubeslice_ui_egs.repo_url' "$yaml_file")
if [ -z "$KUBESLICE_UI_REPO_URL" ] || [ "$KUBESLICE_UI_REPO_URL" = "null" ]; then
KUBESLICE_UI_REPO_URL="$GLOBAL_HELM_REPO_URL"
fi
KUBESLICE_UI_USERNAME=$(yq e '.kubeslice_ui_egs.username' "$yaml_file")
if [ -z "$KUBESLICE_UI_USERNAME" ] || [ "$KUBESLICE_UI_USERNAME" = "null" ]; then
KUBESLICE_UI_USERNAME="$GLOBAL_HELM_USERNAME"
fi
KUBESLICE_UI_PASSWORD=$(yq e '.kubeslice_ui_egs.password' "$yaml_file")
if [ -z "$KUBESLICE_UI_PASSWORD" ] || [ "$KUBESLICE_UI_PASSWORD" = "null" ]; then
KUBESLICE_UI_PASSWORD="$GLOBAL_HELM_PASSWORD"
fi
KUBESLICE_UI_VALUES_FILE=$(yq e '.kubeslice_ui_egs.values_file' "$yaml_file")
KUBESLICE_UI_VALUES_FILE="$BASE_PATH/$KUBESLICE_UI_VALUES_FILE"
KUBESLICE_UI_INLINE_VALUES=$(yq e '.kubeslice_ui_egs.inline_values // {}' "$yaml_file")
KUBESLICE_UI_IMAGE_PULL_SECRET_REPO=$(yq e '.kubeslice_ui_egs.imagePullSecrets.repository' "$yaml_file")
if [ -z "$KUBESLICE_UI_IMAGE_PULL_SECRET_REPO" ] || [ "$KUBESLICE_UI_IMAGE_PULL_SECRET_REPO" = "null" ]; then
KUBESLICE_UI_IMAGE_PULL_SECRET_REPO="$GLOBAL_IMAGE_PULL_SECRET_REPO"
fi
KUBESLICE_UI_IMAGE_PULL_SECRET_USERNAME=$(yq e '.kubeslice_ui_egs.imagePullSecrets.username' "$yaml_file")
if [ -z "$KUBESLICE_UI_IMAGE_PULL_SECRET_USERNAME" ] || [ "$KUBESLICE_UI_IMAGE_PULL_SECRET_USERNAME" = "null" ]; then
KUBESLICE_UI_IMAGE_PULL_SECRET_USERNAME="$GLOBAL_IMAGE_PULL_SECRET_USERNAME"
fi
KUBESLICE_UI_IMAGE_PULL_SECRET_PASSWORD=$(yq e '.kubeslice_ui_egs.imagePullSecrets.password' "$yaml_file")
if [ -z "$KUBESLICE_UI_IMAGE_PULL_SECRET_PASSWORD" ] || [ "$KUBESLICE_UI_IMAGE_PULL_SECRET_PASSWORD" = "null" ]; then
KUBESLICE_UI_IMAGE_PULL_SECRET_PASSWORD="$GLOBAL_IMAGE_PULL_SECRET_PASSWORD"
fi
KUBESLICE_UI_IMAGE_PULL_SECRET_EMAIL=$(yq e '.kubeslice_ui_egs.imagePullSecrets.email' "$yaml_file")
if [ -z "$KUBESLICE_UI_IMAGE_PULL_SECRET_EMAIL" ] || [ "$KUBESLICE_UI_IMAGE_PULL_SECRET_EMAIL" = "null" ]; then
KUBESLICE_UI_IMAGE_PULL_SECRET_EMAIL="$GLOBAL_IMAGE_PULL_SECRET_EMAIL"
fi
KUBESLICE_UI_HELM_FLAGS=$(yq e '.kubeslice_ui_egs.helm_flags' "$yaml_file")
KUBESLICE_UI_VERIFY_INSTALL=$(yq e '.kubeslice_ui_egs.verify_install' "$yaml_file")
if [ -z "$KUBESLICE_UI_VERIFY_INSTALL" ] || [ "$KUBESLICE_UI_VERIFY_INSTALL" = "null" ]; then
KUBESLICE_UI_VERIFY_INSTALL="$GLOBAL_VERIFY_INSTALL"
fi
KUBESLICE_UI_VERIFY_INSTALL_TIMEOUT=$(yq e '.kubeslice_ui_egs.verify_install_timeout' "$yaml_file")
if [ -z "$KUBESLICE_UI_VERIFY_INSTALL_TIMEOUT" ] || [ "$KUBESLICE_UI_VERIFY_INSTALL_TIMEOUT" = "null" ]; then
KUBESLICE_UI_VERIFY_INSTALL_TIMEOUT="$GLOBAL_VERIFY_INSTALL_TIMEOUT"
fi
KUBESLICE_UI_SKIP_ON_VERIFY_FAIL=$(yq e '.kubeslice_ui_egs.skip_on_verify_fail' "$yaml_file")
if [ -z "$KUBESLICE_UI_SKIP_ON_VERIFY_FAIL" ] || [ "$KUBESLICE_UI_SKIP_ON_VERIFY_FAIL" = "null" ]; then
KUBESLICE_UI_SKIP_ON_VERIFY_FAIL="$GLOBAL_SKIP_ON_VERIFY_FAIL"
fi
# Extract values for kubeslice-worker-egs
WORKERS_COUNT=$(yq e '.kubeslice_worker_egs | length' "$yaml_file")
KUBESLICE_WORKERS=()
for ((i = 0; i < WORKERS_COUNT; i++)); do
WORKER_NAME=$(yq e ".kubeslice_worker_egs[$i].name" "$yaml_file")
WORKER_SKIP_INSTALLATION=$(yq e ".kubeslice_worker_egs[$i].skip_installation" "$yaml_file")
WORKER_USE_GLOBAL_KUBECONFIG=$(yq e ".kubeslice_worker_egs[$i].use_global_kubeconfig" "$yaml_file")
if [ -z "$WORKER_USE_GLOBAL_KUBECONFIG" ] || [ "$WORKER_USE_GLOBAL_KUBECONFIG" = "null" ]; then
WORKER_USE_GLOBAL_KUBECONFIG="true"
fi
WORKER_KUBECONFIG=$(yq e ".kubeslice_worker_egs[$i].kubeconfig" "$yaml_file")
WORKER_KUBECONFIG="${WORKER_KUBECONFIG:-$GLOBAL_KUBECONFIG}"
WORKER_KUBECONTEXT=$(yq e ".kubeslice_worker_egs[$i].kubecontext" "$yaml_file")
if [ -z "$WORKER_KUBECONTEXT" ] || [ "$WORKER_KUBECONTEXT" = "null" ]; then
WORKER_KUBECONTEXT="$GLOBAL_KUBECONTEXT"
fi
WORKER_NAMESPACE=$(yq e ".kubeslice_worker_egs[$i].namespace" "$yaml_file")
WORKER_RELEASE_NAME=$(yq e ".kubeslice_worker_egs[$i].release" "$yaml_file")
WORKER_CHART_NAME=$(yq e ".kubeslice_worker_egs[$i].chart" "$yaml_file")
WORKER_REPO_URL=$(yq e ".kubeslice_worker_egs[$i].repo_url" "$yaml_file")
if [ -z "$WORKER_REPO_URL" ] || [ "$WORKER_REPO_URL" = "null" ]; then
WORKER_REPO_URL="$GLOBAL_HELM_REPO_URL"
fi
WORKER_USERNAME=$(yq e ".kubeslice_worker_egs[$i].username" "$yaml_file")
if [ -z "$WORKER_USERNAME" ] || [ "$WORKER_USERNAME" = "null" ]; then
WORKER_USERNAME="$GLOBAL_HELM_USERNAME"
fi
WORKER_PASSWORD=$(yq e ".kubeslice_worker_egs[$i].password" "$yaml_file")
if [ -z "$WORKER_PASSWORD" ] || [ "$WORKER_PASSWORD" = "null" ]; then
WORKER_PASSWORD="$GLOBAL_HELM_PASSWORD"
fi
WORKER_VALUES_FILE=$(yq e ".kubeslice_worker_egs[$i].values_file" "$yaml_file")
WORKER_VALUES_FILE="$BASE_PATH/$WORKER_VALUES_FILE"
WORKER_INLINE_VALUES=$(yq e ".kubeslice_worker_egs[$i].inline_values // {}" "$yaml_file")
WORKER_IMAGE_PULL_SECRET_REPO=$(yq e ".kubeslice_worker_egs[$i].imagePullSecrets.repository" "$yaml_file")
if [ -z "$WORKER_IMAGE_PULL_SECRET_REPO" ] || [ "$WORKER_IMAGE_PULL_SECRET_REPO" = "null" ]; then
WORKER_IMAGE_PULL_SECRET_REPO="$GLOBAL_IMAGE_PULL_SECRET_REPO"
fi
WORKER_IMAGE_PULL_SECRET_USERNAME=$(yq e ".kubeslice_worker_egs[$i].imagePullSecrets.username" "$yaml_file")
if [ -z "$WORKER_IMAGE_PULL_SECRET_USERNAME" ] || [ "$WORKER_IMAGE_PULL_SECRET_USERNAME" = "null" ]; then
WORKER_IMAGE_PULL_SECRET_USERNAME="$GLOBAL_IMAGE_PULL_SECRET_USERNAME"
fi
WORKER_IMAGE_PULL_SECRET_PASSWORD=$(yq e ".kubeslice_worker_egs[$i].imagePullSecrets.password" "$yaml_file")
if [ -z "$WORKER_IMAGE_PULL_SECRET_PASSWORD" ] || [ "$WORKER_IMAGE_PULL_SECRET_PASSWORD" = "null" ]; then
WORKER_IMAGE_PULL_SECRET_PASSWORD="$GLOBAL_IMAGE_PULL_SECRET_PASSWORD"
fi
WORKER_IMAGE_PULL_SECRET_EMAIL=$(yq e ".kubeslice_worker_egs[$i].imagePullSecrets.email" "$yaml_file")
if [ -z "$WORKER_IMAGE_PULL_SECRET_EMAIL" ] || [ "$WORKER_IMAGE_PULL_SECRET_EMAIL" = "null" ]; then
WORKER_IMAGE_PULL_SECRET_EMAIL="$GLOBAL_IMAGE_PULL_SECRET_EMAIL"
fi
WORKER_HELM_FLAGS=$(yq e ".kubeslice_worker_egs[$i].helm_flags" "$yaml_file")
WORKER_VERIFY_INSTALL=$(yq e ".kubeslice_worker_egs[$i].verify_install" "$yaml_file")
if [ -z "$WORKER_VERIFY_INSTALL" ] || [ "$WORKER_VERIFY_INSTALL" = "null" ]; then
WORKER_VERIFY_INSTALL="$GLOBAL_VERIFY_INSTALL"
fi
WORKER_VERIFY_INSTALL_TIMEOUT=$(yq e ".kubeslice_worker_egs[$i].verify_install_timeout" "$yaml_file")
if [ -z "$WORKER_VERIFY_INSTALL_TIMEOUT" ] || [ "$WORKER_VERIFY_INSTALL_TIMEOUT" = "null" ]; then