-
Notifications
You must be signed in to change notification settings - Fork 0
/
provision_cluster-v2.sh
executable file
·2197 lines (1821 loc) · 102 KB
/
provision_cluster-v2.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
# Main program to install CP4I end to end with customisation
# Laurent 2021
# Updated July 2023 Saad / Arnauld
################################################
# @param $1 cp4i properties file path (ex : ./cp4.properties)
# @param $2 cp4i versions file path (ex : ./versions/cp4-16.1.0.properties)
# @param $3 namespace
# @param $4 cluster_name
################################################
################################################
# Log in IBM Cloud
function login_2_ibm_cloud() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 4 "F:IN :login_2_ibm_cloud"
if ! ${TECHZONE}; then
SECONDS=0
if ibmcloud resource groups -q >/dev/null 2>&1; then
mylog info "user already logged to IBM Cloud."
else
mylog info "user not logged to IBM Cloud." 1>&2
var_fail MY_IC_APIKEY "Create and save API key JSON file from: https://cloud.ibm.com/iam/apikeys"
mylog check "Login to IBM Cloud"
if ! ibmcloud login -q --no-region --apikey $MY_IC_APIKEY >/dev/null; then
mylog error "Fail to login to IBM Cloud, check API key: $MY_IC_APIKEY" 1>&2
decho 4 "F:OUT:login_2_ibm_cloud"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
exit 1
else
mylog ok
mylog info "Connecting to IBM Cloud took: $SECONDS seconds." 1>&2
fi
fi
fi
decho 4 "F:OUT:login_2_ibm_cloud"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
######################################################################
# Create openshift cluster if it does not exist
# and wait for both availability of the cluster and the ingress address
function create_openshift_cluster_wait_4_availability() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :create_openshift_cluster_wait_4_availability"
if ! ${TECHZONE}; then
# Create openshift cluster
create_openshift_cluster
# Wait for Cluster availability
wait_for_cluster_availability
# Wait for ingress address availability
wait_4_ingress_address_availability
fi
decho 3 "F:OUT:create_openshift_cluster_wait_4_availability"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
################################################
# Login to openshift cluster
# note that this login requires that you login to the cluster once (using sso or web): not sure why
# requires var my_cluster_url
function login_2_openshift_cluster() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 4 "F:IN :login_2_openshift_cluster"
SECONDS=0
if oc whoami >/dev/null 2>&1; then
mylog info "user already logged to openshift cluster."
else
if $TECHZONE; then
oc login -u ${MY_TECHZONE_USERNAME} -p ${MY_TECHZONE_PASSWORD} ${MY_TECHZONE_OPENSHIFT_API_URL}
else
mylog check "Login to cluster"
# SB 20231208 The following command sets your command line context for the cluster and download the TLS certificates and permission files for the administrator.
# more details here : https://cloud.ibm.com/docs/openshift?topic=openshift-access_cluster#access_public_se
ibmcloud ks cluster config --cluster ${sc_cluster_name} --admin
while ! oc login -u apikey -p $MY_IC_APIKEY --server=$my_cluster_url >/dev/null; do
mylog error "$(date) Fail to login to Cluster, retry in a while (login using web to unblock)" 1>&2
sleep 30
done
mylog ok
mylog info "Logging to Cluster took: $SECONDS seconds." 1>&2
fi
fi
decho 4 "F:OUT:login_2_openshift_cluster"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
################################################
# add ibm entitlement key to namespace
# @param ns namespace where secret is created
function add_ibm_entitlement() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :add_ibm_entitlement"
local lf_in_ns=$1
mylog check "Checking ibm-entitlement-key in $lf_in_ns"
if oc -n $lf_in_ns get secret ibm-entitlement-key >/dev/null 2>&1; then
mylog ok
else
var_fail MY_ENTITLEMENT_KEY "Missing entitlement key"
mylog info "Checking ibm-entitlement-key validity"
$MY_CONTAINER_ENGINE -h >/dev/null 2>&1
if test $? -eq 0 && ! echo $MY_ENTITLEMENT_KEY | $MY_CONTAINER_ENGINE login cp.icr.io --username cp --password-stdin; then
mylog error "Invalid entitlement key" 1>&2
decho 3 "F:OUT:add_ibm_entitlement"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
exit 1
fi
mylog info "Adding ibm-entitlement-key to $lf_in_ns"
if ! oc -n $lf_in_ns create secret docker-registry ibm-entitlement-key --docker-username=cp --docker-password=$MY_ENTITLEMENT_KEY --docker-server=cp.icr.io; then
decho 3 "F:OUT:add_ibm_entitlement"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
exit 1
fi
fi
decho 3 "F:OUT:add_ibm_entitlement"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
################################################
# Install GitOps
function install_gitops() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_gitops"
# https://docs.openshift.com/gitops/1.12/installing_gitops/installing-openshift-gitops.html
mylog info "==== Installing Redhat Openshift GitOps." 1>&2
export MY_NAMESPACE=$MY_GITOPS_NAMESPACE
envsubst <"${MY_RESOURCESDIR}namespace.yaml" | oc apply -f - || exit 1
local lf_operator_name="$MY_GITOPS_OPERATORGROUP"
local lf_operator_namespace=$MY_OPERATORS_NAMESPACE
local lf_operator_chl=$MY_GITOPS_CHL
local lf_strategy="Automatic"
local lf_catalog_source_name="redhat-operators"
local lf_wait_for_state=true
local lf_csv_name=$MY_GITOPS_CASE
decho 3 "create_operator_subscription \"${lf_operator_name}\" \"${lf_operator_namespace}\" \"${lf_operator_chl}\" \"${lf_strategy}\" \"${lf_catalog_source_name}\" \"${lf_wait_for_state}\" \"${lf_csv_name}\""
create_operator_subscription "${lf_operator_name}" "${lf_operator_namespace}" "${lf_operator_chl}" "${lf_strategy}" "${lf_catalog_source_name}" "${lf_wait_for_state}" "${lf_csv_name}"
decho 3 "F:OUT:install_gitops"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
###############################################
# Install CP4I Cluster Logging : Loki log store
# use Openshift Logging
# https://docs.openshift.com/container-platform/4.16/observability/logging/cluster-logging-deploying.html#logging-loki-cli-install_cluster-logging-deploying
function install_logging_loki() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_logging_loki"
# Openshift Logging
if $MY_LOGGING_LOKI; then
mylog info "==== Installing Cluster Logging : Loki log store." 1>&2
# Create a namespace object for Loki Operator
oc apply -f ${MY_RESOURCESDIR}loki-namespace.yaml
# Operator group for Loki in all namespaces
local lf_type="OperatorGroup"
local lf_cr_name="${MY_LOKI_OPERATORGROUP}"
local lf_yaml_file="${MY_RESOURCESDIR}operator-group-all.yaml"
local lf_namespace="openshift-operators-redhat"
check_create_oc_yaml "${lf_type}" "${lf_cr_name}" "${lf_yaml_file}" "${lf_namespace}"
# Create a subscription object for Loki Operator
local lf_operator_name=$MY_LOKI_OPERATOR
local lf_operator_namespace="openshift-operators-redhat"
local lf_operator_chl=$MY_LOKI_CHL
local lf_strategy="Automatic"
local lf_catalog_source_name="redhat-operators"
local lf_wait_for_state=true
local lf_csv_name=$MY_LOKI_OPERATOR
decho 3 "create_operator_subscription \"${lf_operator_name}\" \"${lf_operator_namespace}\" \"${lf_operator_chl}\" \"${lf_strategy}\" \"${lf_catalog_source_name}\" \"${lf_wait_for_state}\" \"${lf_csv_name}\""
create_operator_subscription "${lf_operator_name}" "${lf_operator_namespace}" "${lf_operator_chl}" "${lf_strategy}" "${lf_catalog_source_name}" "${lf_wait_for_state}" "${lf_csv_name}"
# Create a namespace object for Red Hat Openshift Logging Operator
oc apply -f ${MY_RESOURCESDIR}rhel-logging-namespace.yaml
# Create an OperatorGroup object for Red Hat Openhsift Logging Operator
local lf_type="OperatorGroup"
local lf_cr_name="${MY_LOGGING_OPERATORGROUP}"
local lf_yaml_file="${MY_RESOURCESDIR}operator-group-single.yaml"
local lf_namespace=$MY_LOGGING_NAMESPACE
export MY_OPERATORGROUP="${MY_LOGGING_OPERATORGROUP}"
check_create_oc_yaml "${lf_type}" "${lf_cr_name}" "${lf_yaml_file}" "${lf_namespace}"
# Create a subscription object for Red Hat Openshift Logging Operator
local lf_operator_name=$MY_LOGGING_OPERATORGROUP
local lf_operator_namespace="${MY_LOGGING_NAMESPACE}"
local lf_operator_chl=$MY_LOKI_CHL
local lf_strategy="Automatic"
local lf_catalog_source_name="redhat-operators"
local lf_wait_for_state=true
local lf_csv_name=$MY_LOGGING_OPERATORGROUP
#export MY_STARTING_CSV="${MY_LOKI_STARTINGCSV}"
decho 3 "create_operator_subscription \"${lf_operator_name}\" \"${lf_operator_namespace}\" \"${lf_operator_chl}\" \"${lf_strategy}\" \"${lf_catalog_source_name}\" \"${lf_wait_for_state}\" \"${lf_csv_name}\""
create_operator_subscription "${lf_operator_name}" "${lf_operator_namespace}" "${lf_operator_chl}" "${lf_strategy}" "${lf_catalog_source_name}" "${lf_wait_for_state}" "${lf_csv_name}"
# create an ObjectBucketClaim in openshift-logging namespace
# https://docs.openshift.com/container-platform/4.16/observability/logging/log_storage/installing-log-storage.html#logging-loki-storage-odf_installing-log-storage
local lf_operator_namespace=$MY_LOGGING_NAMESPACE
local lf_type="ObjectBucketClaim"
local lf_cr_name=$MY_LOKI_BUCKET_INSTANCE_NAME
local lf_yaml_file="${MY_RESOURCESDIR}objectbucketclaim.yaml"
decho 3 "check_create_oc_yaml \"${lf_type}\" \"${lf_cr_name}\" \"${lf_yaml_file}\" \"${lf_operator_namespace}\""
check_create_oc_yaml "${lf_type}" "${lf_cr_name}" "${lf_yaml_file}" "${lf_operator_namespace}"
# get the needed parameters to create the object storage secret
export MY_LOKI_ACCESS_KEY_ID=$(oc get -n openshift-storage secret rook-ceph-object-user-ocs-storagecluster-cephobjectstore-noobaa-ceph-objectstore-user -o jsonpath='{.data.AccessKey}'| base64 --decode)
export MY_LOKI_ACCESS_KEY_SECRET=$(oc get -n openshift-storage secret rook-ceph-object-user-ocs-storagecluster-cephobjectstore-noobaa-ceph-objectstore-user -o jsonpath='{.data.SecretKey}'| base64 --decode)
export MY_LOKI_ENDPOINT=$(oc get -n openshift-storage secret rook-ceph-object-user-ocs-storagecluster-cephobjectstore-noobaa-ceph-objectstore-user -o jsonpath='{.data.Endpoint}'| base64 --decode)
local lf_operator_namespace="${MY_LOGGING_NAMESPACE}"
local lf_type="Secret"
local lf_cr_name=$MY_LOKI_SECRET
local lf_yaml_file="${MY_RESOURCESDIR}loki-secret.yaml"
decho 3 "MY_LOKI_ACCESS_KEY_ID=$MY_LOKI_ACCESS_KEY_ID|MY_LOKI_ACCESS_KEY_SECRET=$MY_LOKI_ACCESS_KEY_SECRET|MY_LOKI_ENDPOINT=$MY_LOKI_ENDPOINT"
decho 3 "check_create_oc_yaml \"${lf_type}\" \"${lf_cr_name}\" \"${lf_yaml_file}\" \"${lf_operator_namespace}\""
check_create_oc_yaml "${lf_type}" "${lf_cr_name}" "${lf_yaml_file}" "${lf_operator_namespace}"
# Create a LokiStack instance
local lf_file="${MY_OPERANDSDIR}Loki-Capability.yaml"
local lf_ns=$MY_LOGGING_NAMESPACE
local lf_path="{.status.conditions[0].type}"
local lf_resource="$MY_LOKI_INSTANCE_NAME"
local lf_state="Ready"
local lf_type="LokiStack"
local lf_wait_for_state=true
create_operand_instance "${lf_file}" "${lf_ns}" "${lf_path}" "${lf_resource}" "${lf_state}" "${lf_type}" "${lf_wait_for_state}"
# SB]20241204 Configuring LokiStack log store
# https://docs.openshift.com/container-platform/4.16/observability/logging/log_storage/cluster-logging-loki.html
# Create a new group fro the cluster-admin user role
oc adm groups new cluster-admin
# add the desired user to the cluster-admin group
oc adm groups add-users cluster-admin $MY_USER
# add the cluster-admin user role to the cluster-admin group
oc adm policy add-cluster-role-to-group cluster-admin cluster-admin
# Fine grained access for Loki logs
# https://docs.openshift.com/container-platform/4.16/observability/logging/log_storage/cluster-logging-loki.html#logging-loki-log-access_cluster-logging-loki
# TO DO ?!
# SB]20241125 Attention, depuis la version 6.0 des APIs Logging, plus de ClusterLogging et ClusterLogForwarder:
# Starting with this release, the operator no longer supports the ClusterLogging.logging.openshift.io and ClusterLogForwarder.logging.openshift.io
# custom resources. See the product documentation for additional details about the replacement features.
# https://docs.redhat.com/en/documentation/openshift_container_platform/4.16/html/logging/logging-6-0#log6x0-release-notes
# https://issues.redhat.com/browse/LOG-5803
# https://docs.openshift.com/container-platform/4.16/observability/logging/logging-6.0/log6x-about.html
# https://docs.redhat.com/en/documentation/openshift_container_platform/4.16/html/logging/logging-6-0#quick-start
# https://docs.openshift.com/container-platform/4.16/observability/logging/logging-6.1/log6x-about-6.1.html
# Sur ce dernier lien, dans le pargraphe Quick start sont décrites les deux options suivantes:
# ViaQ (General Availability) et OpenTelemetry (Technology Preview)
# TODO CONFIGURE ClusterLogForwarder
fi
decho 3 "F:OUT:install_logging_loki"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
###############################################
# Install Redhat Cluster Observability Operator
# # https://docs.redhat.com/en/documentation/openshift_container_platform/4.16/html-single/cluster_observability_operator/index#cluster-observability-operator-overview
function install_cluster_observability() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_cluster_observability"
# Openshift Observability
if $MY_COO; then
# Create a service account for the collector
oc create sa $MY_LOGGING_COLLECTOR_SA -n $MY_LOGGING_NAMESPACE
# Create a ClusterRole for the collector
oc apply -f "${MY_RESOURCESDIR}collector-ClusterRole.yaml"
# Bind the ClusterRole to the service account
oc adm policy add-cluster-role-to-user logging-collector-logs-writer -z $MY_LOGGING_COLLECTOR_SA
# SB]20241203 https://docs.redhat.com/en/documentation/openshift_container_platform/4.16/html/logging/logging-6-0#cluster-role-binding-for-your-service-account
envsubst <"${MY_RESOURCESDIR}role_binding.yaml" | oc apply -f - || exit 1
# Install the Cluster Observability Operator
# https://docs.redhat.com/en/documentation/openshift_container_platform/4.16/html-single/cluster_observability_operator/index#cluster-observability-operator-overview
# Create a subscription object for Cluster Observability Operator
local lf_operator_name="$MY_COO_OPERATOR"
local lf_operator_namespace="$MY_OPERATORS_NAMESPACE"
local lf_operator_chl=$MY_COO_CHL
local lf_strategy="Automatic"
local lf_catalog_source_name="redhat-operators"
local lf_wait_for_state=true
local lf_csv_name=$MY_COO_OPERATOR
decho 3 "create_operator_subscription \"${lf_operator_name}\" \"${lf_operator_namespace}\" \"${lf_operator_chl}\" \"${lf_strategy}\" \"${lf_catalog_source_name}\" \"${lf_wait_for_state}\" \"${lf_csv_name}\""
create_operator_subscription "${lf_operator_name}" "${lf_operator_namespace}" "${lf_operator_chl}" "${lf_strategy}" "${lf_catalog_source_name}" "${lf_wait_for_state}" "${lf_csv_name}"
fi
decho 3 "F:OUT:install_cluster_observability"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
###############################################
# Install Logging ViaQ (Create policies for access, will be replaced by OpenTelemetry)
# https://docs.openshift.com/container-platform/4.16/observability/logging/logging-6.1/log6x-about-6.1.html
# Pre requisite : Install the Red Hat OpenShift Logging Operator, Loki Operator, and Cluster Observability Operator (COO)
# Do not forget to login/logout if logs do not appear under the Observe section of the OpenShift Web UI
function install_logging_viaq() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_logging_viaq"
# Openshift Observability
if $MY_COO; then
# Create a service account for the collector
oc create sa $MY_LOGGING_COLLECTOR_SA -n $MY_LOGGING_NAMESPACE
# Allow the collector’s service account to write data to the LokiStack CR
oc adm policy add-cluster-role-to-user logging-collector-logs-writer -z $MY_LOGGING_COLLECTOR_SA
# Allow the collector’s service account to collect logs
oc project $MY_LOGGING_NAMESPACE
oc adm policy add-cluster-role-to-user collect-application-logs -z $MY_LOGGING_COLLECTOR_SA
oc adm policy add-cluster-role-to-user collect-audit-logs -z $MY_LOGGING_COLLECTOR_SA
oc adm policy add-cluster-role-to-user collect-infrastructure-logs -z $MY_LOGGING_COLLECTOR_SA
# Create a UIPlugi CR to enable the Log section in the Observe tab
envsubst <"${MY_RESOURCESDIR}uiplugin.yaml" | oc apply -f - || exit 1
# Create a ClusterLogForwarder CR to configure log forwarding
envsubst <"${MY_RESOURCESDIR}clusterlogforwarder-viaq.yaml" | oc apply -f - || exit 1
fi
decho 3 "F:OUT:install_logging_viaq"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
###############################################
# Install Logging OpenTelemetry
# https://docs.openshift.com/container-platform/4.16/observability/logging/logging-6.1/log6x-about-6.1.html
# Pre requisite : Install the Red Hat OpenShift Logging Operator, Loki Operator, and Cluster Observability Operator (COO)
function install_logging_otel() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_logging_otel"
# Openshift Observability
if $MY_COO; then
# Create a service account for the collector
oc create sa $MY_LOGGING_COLLECTOR_SA -n $MY_LOGGING_NAMESPACE
# Allow the collector’s service account to write data to the LokiStack CR
oc adm policy add-cluster-role-to-user logging-collector-logs-writer -z $MY_LOGGING_COLLECTOR_SA
# Allow the collector’s service account to collect logs
oc project $MY_LOGGING_NAMESPACE
oc adm policy add-cluster-role-to-user collect-application-logs -z $MY_LOGGING_COLLECTOR_SA
oc adm policy add-cluster-role-to-user collect-audit-logs -z $MY_LOGGING_COLLECTOR_SA
oc adm policy add-cluster-role-to-user collect-infrastructure-logs -z $MY_LOGGING_COLLECTOR_SA
# Create a UIPlugin CR to enable the Log section in the Observe tab
decho 3 "install_openshift_monitoring create the UI plugin"
envsubst <"${MY_RESOURCESDIR}uiplugin.yaml" | oc apply -f - || exit 1
# Create a ClusterLogForwarder CR to configure log forwarding
envsubst <"${MY_RESOURCESDIR}clusterlogforwarder-otel.yaml" | oc apply -f - || exit 1
# Bind the ClusterRole to the service account
oc adm policy add-cluster-role-to-user logging-collector-logs-writer -z $MY_LOGGING_COLLECTOR_SA
fi
decho 3 "F:OUT:install_logging_otel"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
###############################################
# Install/Configure Redhat Cluster Monitoring
# https://docs.redhat.com/en/documentation/openshift_container_platform/4.16/html/monitoring/index
# https://docs.redhat.com/en/documentation/openshift_container_platform/4.16/html/monitoring/common-monitoring-configuration-scenarios#configuring-core-platform-monitoring-postinstallation-steps_common-monitoring-configuration-scenarios
#
function install_cluster_monitoring() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_cluster_monitoring"
# Openshift cluster monitoring
if $MY_CLUSTER_MONITORING; then
# Create the cluster-monitoring-config cm
export MY_MONITORING_CM_NAME="cluster-monitoring-config"
export MY_MONITORING_NAMESPACE="openshift-monitoring"
envsubst <"${MY_RESOURCESDIR}monitoring-cm.yaml" | oc apply -f - || exit 1
# Enable monitoring for user-defines projects
# If you enable monitoring for user-defined projects, the user-workload-monitoring-config ConfigMap object is created by default.
# The enableUserWorkload parameter enables monitoring for user-defined projects in the OpenShift cluster.
# This action creates a prometheus-operated service in the openshift-user-workload-monitoring namespace.
#export MY_MONITORING_CM_NAME="user-workload-monitoring-config"
#export MY_MONITORING_NAMESPACE="openshift-user-workload-monitoring"
#envsubst <"${MY_RESOURCESDIR}monitoring-cm.yaml" | oc apply -f - || exit 1
oc patch configmap cluster-monitoring-config -n openshift-monitoring --type=merge --patch '{"data":{"config.yaml":"enableUserWorkload: true\n"}}'
# Granting users permissions for core platform monitoring
fi
decho 3 "F:OUT:install_cluster_monitoring"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
##################################################
# Install OADP (OpenShift API for Data Protection)
function install_oadp() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_oadp"
mylog info "==== Redhat Openshift OADP." 1>&2
# OpenShift restricts creating namespaces with the openshift- prefix via oc create namespace.
# However, you can bypass this limitation using oc apply:
# create_namespace $MY_OADP_NAMESPACE
export MY_NAMESPACE=$MY_OADP_NAMESPACE
envsubst <"${MY_RESOURCESDIR}namespace.yaml" | oc apply -f - || exit 1
# Operator group for OADP in single namespace
local lf_type="OperatorGroup"
local lf_cr_name="${MY_OADP_OPERATORGROUP}"
local lf_yaml_file="${MY_RESOURCESDIR}operator-group-single.yaml"
local lf_namespace=$MY_OADP_NAMESPACE
check_create_oc_yaml "${lf_type}" "${lf_cr_name}" "${lf_yaml_file}" "${lf_namespace}"
# SB]20241120 Pour obtenir le template de l'operateur oadp de Redhat, je l'ai installé avec la console, j'ai récupéré le Yaml puis désinstallé.
local lf_operator_name="redhat-oadp-operator"
local lf_operator_namespace=$MY_OADP_NAMESPACE
local lf_operator_chl=$MY_OADP_CHL
local lf_strategy="Automatic"
local lf_catalog_source_name="redhat-operators"
local lf_wait_for_state=true
local lf_csv_name=$MY_OADP_OPERATOR
decho 3 "create_operator_subscription \"${lf_operator_name}\" \"${lf_operator_namespace}\" \"${lf_operator_chl}\" \"${lf_strategy}\" \"${lf_catalog_source_name}\" \"${lf_wait_for_state}\" \"${lf_csv_name}\""
create_operator_subscription "${lf_operator_name}" "${lf_operator_namespace}" "${lf_operator_chl}" "${lf_strategy}" "${lf_catalog_source_name}" "${lf_wait_for_state}" "${lf_csv_name}"
decho 3 "F:OUT:install_oadp"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
################################################
# Install redhat Pipelines (tekton)
function install_pipelines() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_pipelines"
# https://docs.openshift.com/pipelines/1.14/install_config/installing-pipelines.html
mylog info "==== Redhat Openshift Pipelines (tekton)." 1>&2
local lf_operator_name="$MY_PIPELINES_OPERATORGROUP"
local lf_operator_namespace=$MY_OPERATORS_NAMESPACE
local lf_operator_chl="latest"
local lf_strategy="Automatic"
local lf_catalog_source_name="redhat-operators"
local lf_wait_for_state=true
local lf_csv_name=$MY_PIPELINES_CASE
decho 3 "create_operator_subscription \"${lf_operator_name}\" \"${lf_operator_namespace}\" \"${lf_operator_chl}\" \"${lf_strategy}\" \"${lf_catalog_source_name}\" \"${lf_wait_for_state}\" \"${lf_csv_name}\""
create_operator_subscription "${lf_operator_name}" "${lf_operator_namespace}" "${lf_operator_chl}" "${lf_strategy}" "${lf_catalog_source_name}" "${lf_wait_for_state}" "${lf_csv_name}"
decho 3 "F:OUT:install_pipelines"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
################################################
# Add mailhog app to openshift
# Port is hard coded to 8025 and is defined by mailhog (default port)
function install_mailhog() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_mailhog"
if $MY_MAILHOG; then
mylog info "==== Installing mailhog (server and client)." 1>&2
local lf_type="deployment"
local lf_name="mailhog"
# May need some properties
# read_config_file "${MY_YAMLDIR}ldap/ldap.properties"
# create namespace if needed
create_namespace ${MY_MAIL_SERVER_NAMESPACE}
deploy_mailhog ${lf_type} ${lf_name} ${MY_MAIL_SERVER_NAMESPACE}
expose_service_mailhog ${lf_name} ${MY_MAIL_SERVER_NAMESPACE} '8025'
fi
decho 3 "F:OUT:install_mailhog"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
################################################
# Add OpenLdap app to openshift
function install_openldap() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_openldap"
if $MY_LDAP; then
mylog info "==== Installing OpenLdap." 1>&2
local lf_type="deployment"
local lf_name="openldap"
read_config_file "${MY_YAMLDIR}ldap/ldap.properties"
# create namespace if needed
create_namespace ${MY_LDAP_NAMESPACE}
#SB]20231207 checks if used directories and files exists
check_file_exist ${MY_YAMLDIR}ldap/ldap-pvc.main.yaml
check_file_exist ${MY_YAMLDIR}ldap/ldap-pvc.config.yaml
check_file_exist ${MY_YAMLDIR}ldap/ldap-config.json
check_file_exist ${MY_YAMLDIR}ldap/ldap-users.ldif
provision_persistence_openldap ${MY_LDAP_NAMESPACE}
deploy_openldap ${lf_type} ${lf_name} ${MY_LDAP_NAMESPACE}
expose_service_openldap ${lf_name} ${MY_LDAP_NAMESPACE}
fi
decho 3 "F:OUT:install_openldap"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
################################################
# Install Cert Manager
function install_cert_manager() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_cert_manager"
mylog info "==== Redhat Cert Manager catalog." 1>&2
lf_catalogsource_namespace=$MY_CATALOGSOURCES_NAMESPACE
lf_catalogsource_name="redhat-operators"
lf_catalogsource_dspname="Red Hat Operators"
lf_catalogsource_image="registry.redhat.io/redhat/redhat-operator-index:v4.12"
lf_catalogsource_publisher="Red Hat"
lf_catalogsource_interval="10m"
decho 3 "create_catalogsource \"${lf_catalogsource_namespace}\" \"${lf_catalogsource_name}\" \"${lf_catalogsource_dspname}\" \"${lf_catalogsource_image}\" \"${lf_catalogsource_publisher}\" \"${lf_catalogsource_interval}\""
create_catalogsource "${lf_catalogsource_namespace}" "${lf_catalogsource_name}" "${lf_catalogsource_dspname}" "${lf_catalogsource_image}" "${lf_catalogsource_publisher}" "${lf_catalogsource_interval}"
# SB]20231215 Pour obtenir le template de l'operateur cert-manager de Redhat, je l'ai installé avec la console, j'ai récupéré le Yaml puis désinstallé.
local lf_operator_name="openshift-cert-manager-operator"
local lf_operator_namespace=$MY_CERTMANAGER_NAMESPACE
local lf_operator_chl=$MY_CERT_MANAGER_CHL
local lf_strategy="Automatic"
local lf_catalog_source_name="redhat-operators"
local lf_wait_for_state=true
local lf_csv_name=$MY_CERTMANAGER_CASE
decho 3 "create_operator_subscription \"${lf_operator_name}\" \"${lf_operator_namespace}\" \"${lf_operator_chl}\" \"${lf_strategy}\" \"${lf_catalog_source_name}\" \"${lf_wait_for_state}\" \"${lf_csv_name}\""
create_operator_subscription "${lf_operator_name}" "${lf_operator_namespace}" "${lf_operator_chl}" "${lf_strategy}" "${lf_catalog_source_name}" "${lf_wait_for_state}" "${lf_csv_name}"
decho 3 "F:OUT:install_cert_manager"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
################################################
# Install Licensing Server
function install_lic_srv() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_lic_srv"
# ibm-license-server
if $MY_LIC_SRV; then
mylog info "==== IBM License Server." 1>&2
check_add_cs_ibm_pak ibm-licensing amd64
# Operator group for License Service Reporter in single namespace
ls_type="OperatorGroup"
ls_cr_name="${MY_LICENSE_SERVER_OPERATORGROUP}"
ls_yaml_file="${MY_RESOURCESDIR}operator-group-single.yaml"
ls_namespace=$MY_LICENSE_SERVER_NAMESPACE
check_create_oc_yaml "${ls_type}" "${ls_cr_name}" "${ls_yaml_file}" "${ls_namespace}"
#mylog info "Creating Licensing service catalog source in ns : openshift-marketplace." 1>&2
lf_catalogsource_namespace=$MY_CATALOGSOURCES_NAMESPACE
lf_catalogsource_name="ibm-licensing-catalog"
lf_catalogsource_dspname="ibm-licensing"
lf_catalogsource_image="icr.io/cpopen/ibm-licensing-catalog"
lf_catalogsource_publisher="IBM"
lf_catalogsource_interval="45m"
decho 3 "create_catalogsource \"${lf_catalogsource_namespace}\" \"${lf_catalogsource_name}\" \"${lf_catalogsource_dspname}\" \"${lf_catalogsource_image}\" \"${lf_catalogsource_publisher}\" \"${lf_catalogsource_interval}\""
create_catalogsource "${lf_catalogsource_namespace}" "${lf_catalogsource_name}" "${lf_catalogsource_dspname}" "${lf_catalogsource_image}" "${lf_catalogsource_publisher}" "${lf_catalogsource_interval}"
#mylog info "Creating License Service Reporter catalog source in ns : openshift-marketplace." 1>&2
lf_catalogsource_namespace=$MY_CATALOGSOURCES_NAMESPACE
lf_catalogsource_name="ibm-license-service-reporter-operator-catalog"
lf_catalogsource_dspname="IBM License Service Reporter Catalog"
lf_catalogsource_image="icr.io/cpopen/ibm-license-service-reporter-operator-catalog"
lf_catalogsource_publisher="IBM"
lf_catalogsource_interval="45m"
decho 3 "create_catalogsource \"${lf_catalogsource_namespace}\" \"${lf_catalogsource_name}\" \"${lf_catalogsource_dspname}\" \"${lf_catalogsource_image}\" \"${lf_catalogsource_publisher}\" \"${lf_catalogsource_interval}\""
create_catalogsource "${lf_catalogsource_namespace}" "${lf_catalogsource_name}" "${lf_catalogsource_dspname}" "${lf_catalogsource_image}" "${lf_catalogsource_publisher}" "${lf_catalogsource_interval}"
# ATTENTION : pour le licensing server ajouter dans la partie spec.startingCSV: ibm-licensing-operator.v4.2.1 (sinon erreur).
local lf_operator_name="ibm-licensing-operator-app"
local lf_operator_namespace=$MY_LICENSE_SERVER_NAMESPACE
local lf_operator_chl=$MY_LIC_SRV_CHL
local lf_strategy="Automatic"
local lf_catalog_source_name="ibm-licensing-catalog"
local lf_wait_for_state=true
local lf_csv_name=$MY_LICENSE_SERVER_CASE
decho 3 "create_operator_subscription \"${lf_operator_name}\" \"${lf_operator_namespace}\" \"${lf_operator_chl}\" \"${lf_strategy}\" \"${lf_catalog_source_name}\" \"${lf_wait_for_state}\" \"${lf_csv_name}\""
create_operator_subscription "${lf_operator_name}" "${lf_operator_namespace}" "${lf_operator_chl}" "${lf_strategy}" "${lf_catalog_source_name}" "${lf_wait_for_state}" "${lf_csv_name}"
mylog info "Installing the License Service Reporter operator" 1>&2
local lf_operator_name="ibm-license-service-reporter-operator"
local lf_operator_namespace=$MY_LICENSE_SERVER_NAMESPACE
local lf_operator_chl=$MY_LIC_SRV_CHL
local lf_strategy="Automatic"
local lf_catalog_source_name="ibm-license-service-reporter-operator-catalog"
local lf_wait_for_state=true
local lf_csv_name=$MY_LICENSE_SERVER_REPORTER_CASE
decho 3 "create_operator_subscription \"${lf_operator_name}\" \"${lf_operator_namespace}\" \"${lf_operator_chl}\" \"${lf_strategy}\" \"${lf_catalog_source_name}\" \"${lf_wait_for_state}\" \"${lf_csv_name}\""
create_operator_subscription "${lf_operator_name}" "${lf_operator_namespace}" "${lf_operator_chl}" "${lf_strategy}" "${lf_catalog_source_name}" "${lf_wait_for_state}" "${lf_csv_name}"
mylog info "Creating the License Service Reporter instance" 1>&2
# Creating Creating the License Service Reporter instance
lf_file="${MY_OPERANDSDIR}LIC-Reporter-Capability.yaml"
lf_ns="${MY_LICENSE_SERVER_NAMESPACE}"
lf_path="{.status.conditions[0].type}"
lf_resource="$MY_LICENSE_SERVER_REPORTER_INSTANCE_NAME"
lf_state="Ready"
lf_type="IBMLicenseServiceReporter"
lf_wait_for_state=false
create_operand_instance "${lf_file}" "${lf_ns}" "${lf_path}" "${lf_resource}" "${lf_state}" "${lf_type}" "${lf_wait_for_state}"
# Add license service to the reporter
# oc get routes -n ibm-licensing | grep ibm-license-service-reporter | awk '{print $2}'
mylog info "Add license service to the reporter" 1>&2
lf_licensing_service_reporter_url=$(oc -n ${MY_LICENSE_SERVER_NAMESPACE} get Route -o=jsonpath='{.items[?(@.metadata.name=="ibm-license-service-reporter")].spec.host}')
oc patch -n $MY_LICENSE_SERVER_NAMESPACE IBMLicensing instance --type merge --patch "{\"spec\":{\"sender\":{\"reporterSecretToken\":\"ibm-license-service-reporter-token\",\"reporterURL\":\"https://$lf_licensing_service_reporter_url/\",\"clusterID\":\"MyClusterTest1\",\"clusterName\":\"MyClusterTest1\"}}}"
fi
decho 3 "F:OUT:install_lic_srv"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
############################################################################################################################################
#SB]20231214 Installing Foundational services v4.3
# Referring to https://www.ibm.com/docs/en/cloud-paks/cp-integration/2023.4?topic=whats-new-in-cloud-pak-integration-202341
# "The IBM Cloud Pak foundational services operator is no longer installed automatically.
# Install this operator manually if you need to create an instance that uses identity and access management.
# Also, make sure you have a certificate manager; otherwise, the IBM Cloud Pak foundational services operator installation will not complete."
# This function implements the following steps described here :
############################################################################################################################################
function install_fs() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_fs"
mylog info "==== IBM Common Services." 1>&2
# ibm-cp-common-services
check_add_cs_ibm_pak $MY_COMMONSERVICES_CASE amd64 $MY_COMMONSERVICES_VERSION
lf_catalogsource_namespace=$MY_CATALOGSOURCES_NAMESPACE
lf_catalogsource_name="opencloud-operators"
lf_catalogsource_dspname="IBMCS Operators"
lf_catalogsource_image="icr.io/cpopen/ibm-common-service-catalog:4.3"
lf_catalogsource_publisher="IBM"
lf_catalogsource_interval="45m"
decho 3 "create_catalogsource \"${lf_catalogsource_namespace}\" \"${lf_catalogsource_name}\" \"${lf_catalogsource_dspname}\" \"${lf_catalogsource_image}\" \"${lf_catalogsource_publisher}\" \"${lf_catalogsource_interval}\""
create_catalogsource "${lf_catalogsource_namespace}" "${lf_catalogsource_name}" "${lf_catalogsource_dspname}" "${lf_catalogsource_image}" "${lf_catalogsource_publisher}" "${lf_catalogsource_interval}"
local lf_operator_name="ibm-common-service-operator"
local lf_operator_namespace=$MY_OPERATORS_NAMESPACE
local lf_operator_chl=$MY_FOUNDATIONALSERVICES_CHL
local lf_strategy="Automatic"
local lf_catalog_source_name="opencloud-operators"
local lf_wait_for_state=true
local lf_csv_name="ibm-common-service-operator"
decho 3 "create_operator_subscription \"${lf_operator_name}\" \"${lf_operator_namespace}\" \"${lf_operator_chl}\" \"${lf_strategy}\" \"${lf_catalog_source_name}\" \"${lf_wait_for_state}\" \"${lf_csv_name}\""
create_operator_subscription "${lf_operator_name}" "${lf_operator_namespace}" "${lf_operator_chl}" "${lf_strategy}" "${lf_catalog_source_name}" "${lf_wait_for_state}" "${lf_csv_name}"
## Setting hardware Accept the license to use foundational services by adding spec.license.accept: true in the spec section.
#accept_license_fs $MY_OPERATORS_NAMESPACE
accept_license_fs $lf_operator_namespace
# Configuring foundational services by using the CommonService custom resource.
local lf_operator_namespace=$MY_OPERATORS_NAMESPACE
local lf_type="CommonService"
local lf_cr_name=$MY_COMMONSERVICES_INSTANCE_NAME
local lf_yaml_file="${MY_RESOURCESDIR}foundational-services-cr.yaml"
decho 3 "check_create_oc_yaml \"${lf_type}\" \"${lf_cr_name}\" \"${lf_yaml_file}\" \"${lf_operator_namespace}\""
check_create_oc_yaml "${lf_type}" "${lf_cr_name}" "${lf_yaml_file}" "${lf_operator_namespace}"
decho 3 "F:OUT:install_fs"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
################################################
# Install Open Liberty
function install_openliberty() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_openliberty"
# backend J2EE applications
if $MY_OPENLIBERTY; then
mylog info "==== Installing OPEN Liberty." 1>&2
create_namespace $MY_BACKEND_NAMESPACE
# TODO other approach is to use the catalog which already inludes the Open Liberty operator and use a subscription
# Case exists 1.3.1, and IBM/RedHat Catalog
export OPEN_LIBERTY_OPERATOR_NAMESPACE=$MY_BACKEND_NAMESPACE
export OPEN_LIBERTY_OPERATOR_WATCH_NAMESPACE=$MY_BACKEND_NAMESPACE
# TODO Check that is this value
export WATCH_NAMESPACE='""'
adapt_file ${MY_OPENLIBERTY_SCRIPTDIR}config/ ${MY_OPENLIBERTY_GEN_CUSTOMDIR}config/ openliberty-app-rbac-watch-all.yaml
adapt_file ${MY_OPENLIBERTY_SCRIPTDIR}config/ ${MY_OPENLIBERTY_GEN_CUSTOMDIR}config/ openliberty-app-crd.yaml
adapt_file ${MY_OPENLIBERTY_SCRIPTDIR}config/ ${MY_OPENLIBERTY_GEN_CUSTOMDIR}config/ openliberty-app-operator.yaml
# Creating Open Liberty operator subscription (Check arbitrarely one resource, the deployment of the operator)
local lf_octype='deployment'
local lf_name='olo-controller-manager'
# check if deployment of the operator already performed
mylog check "Checking ${lf_octype} ${lf_name} in ${MY_BACKEND_NAMESPACE}"
if oc -n ${MY_BACKEND_NAMESPACE} get ${lf_octype} ${lf_name} >/dev/null 2>&1; then
mylog ok
else
oc apply --server-side -f ${MY_OPENLIBERTY_GEN_CUSTOMDIR}config/openliberty-app-crd.yaml
oc apply -f ${MY_OPENLIBERTY_GEN_CUSTOMDIR}config/openliberty-app-rbac-watch-all.yaml
oc apply -n ${MY_BACKEND_NAMESPACE} -f ${MY_OPENLIBERTY_GEN_CUSTOMDIR}config/openliberty-app-operator.yaml
fi
fi
decho 3 "F:OUT:install_openliberty"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
################################################
# Install WebSphere Liberty
function install_wasliberty() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_wasliberty"
if $MY_WASLIBERTY; then
mylog info "==== Installing WAS Liberty." 1>&2
create_namespace $MY_BACKEND_NAMESPACE
# add catalog sources using ibm_pak plugin
check_add_cs_ibm_pak $MY_WL_CASE amd64
# mylog info "==== Adding IBM Operator catalog source in ns : openshift-marketplace." 1>&2
lf_catalogsource_namespace=$MY_CATALOGSOURCES_NAMESPACE
lf_catalogsource_name="ibm-operator-catalog"
lf_catalogsource_dspname="IBM Operator Catalog"
lf_catalogsource_image="icr.io/cpopen/ibm-operator-catalog"
lf_catalogsource_publisher="IBM"
lf_catalogsource_interval="45m"
decho 3 "create_catalogsource \"${lf_catalogsource_namespace}\" \"${lf_catalogsource_name}\" \"${lf_catalogsource_dspname}\" \"${lf_catalogsource_image}\" \"${lf_catalogsource_publisher}\" \"${lf_catalogsource_interval}\""
create_catalogsource "${lf_catalogsource_namespace}" "${lf_catalogsource_name}" "${lf_catalogsource_dspname}" "${lf_catalogsource_image}" "${lf_catalogsource_publisher}" "${lf_catalogsource_interval}"
# Operator group for WAS Liberty in single namespace
lf_type="OperatorGroup"
lf_cr_name="${MY_WAS_LIBERTY_OPERATORGROUP}"
lf_yaml_file="${MY_RESOURCESDIR}operator-group-single.yaml"
lf_namespace=$MY_BACKEND_NAMESPACE
decho 3 "check_create_oc_yaml \"${lf_type}\" \"${lf_cr_name}\" \"${lf_yaml_file}\" \"${lf_namespace}\""
check_create_oc_yaml "${lf_type}" "${lf_cr_name}" "${lf_yaml_file}" "${lf_namespace}"
# Creating WebSphere Liberty operator subscription
local lf_operator_name="ibm-websphere-liberty"
local lf_operator_namespace=$MY_BACKEND_NAMESPACE
local lf_operator_chl=$MY_WL_CHL
local lf_strategy="Automatic"
local lf_catalog_source_name="ibm-operator-catalog"
local lf_wait_for_state=true
local lf_csv_name=$MY_WL_CASE
decho 3 "create_operator_subscription \"${lf_operator_name}\" \"${lf_operator_namespace}\" \"${lf_operator_chl}\" \"${lf_strategy}\" \"${lf_catalog_source_name}\" \"${lf_wait_for_state}\" \"${lf_csv_name}\""
create_operator_subscription "${lf_operator_name}" "${lf_operator_namespace}" "${lf_operator_chl}" "${lf_strategy}" "${lf_catalog_source_name}" "${lf_wait_for_state}" "${lf_csv_name}"
fi
decho 3 "F:OUT:install_wasliberty"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
################################################
# Install Navigator (depending on two boolean)
function install_navigator() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_navigator"
## ibm-integration-platform-navigator
# SB,AD]20240103 Suite au pb installation keycloak (besoin de l'operateur IBM Cloud Pak for Integration)
# Creating Navigator operator subscription
if $MY_NAVIGATOR; then
mylog info "==== Installing Navigator." 1>&2
# add catalog sources using ibm_pak plugin
check_add_cs_ibm_pak $MY_NAVIGATOR_CASE amd64
# Creating Navigator operator subscription
local lf_operator_name="$MY_NAVIGATOR_CASE"
local lf_operator_namespace=$MY_OPERATORS_NAMESPACE
local lf_operator_chl=$MY_NAVIGATOR_CHL
local lf_strategy="Automatic"
local lf_catalog_source_name="ibm-integration-platform-navigator-catalog"
local lf_wait_for_state=true
local lf_csv_name=$MY_NAVIGATOR_CASE
decho 3 "create_operator_subscription \"${lf_operator_name}\" \"${lf_operator_namespace}\" \"${lf_operator_chl}\" \"${lf_strategy}\" \"${lf_catalog_source_name}\" \"${lf_wait_for_state}\" \"${lf_csv_name}\""
create_operator_subscription "${lf_operator_name}" "${lf_operator_namespace}" "${lf_operator_chl}" "${lf_strategy}" "${lf_catalog_source_name}" "${lf_wait_for_state}" "${lf_csv_name}"
fi
if $MY_NAVIGATOR_INSTANCE; then
#SB]20240612 prise en compte de l'existence ou non de la variable portant la version
if [ -z "$MY_NAVIGATOR_VERSION" ]; then
export MY_NAVIGATOR_VERSION=$(oc ibm-pak list -o json | jq --arg case "$MY_NAVIGATOR_CASE" '.[] | select (.name == $case ) | .latestAppVersion')
decho 3 "MY_NAVIGATOR_VERSION=$MY_NAVIGATOR_VERSION"
fi
# Creating Navigator instance
lf_file="${MY_OPERANDSDIR}Navigator-Capability.yaml"
lf_ns="${MY_OC_PROJECT}"
lf_path="{.status.conditions[0].type}"
lf_resource="$MY_NAVIGATOR_INSTANCE_NAME"
lf_state="Ready"
lf_type="PlatformNavigator"
lf_wait_for_state=true
create_operand_instance "${lf_file}" "${lf_ns}" "${lf_path}" "${lf_resource}" "${lf_state}" "${lf_type}" "${lf_wait_for_state}"
fi
decho 3 "F:OUT:install_navigator"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
################################################
# Install Asset Repository
function install_assetrepo() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_assetrepo"
if $MY_ASSETREPO; then
mylog info "==== Installing Asset Repository." 1>&2
# add catalog sources using ibm_pak plugin
check_add_cs_ibm_pak ibm-integration-asset-repository amd64
# Creating Asset Repository operator subscription
local lf_operator_name="ibm-integration-asset-repository"
local lf_operator_namespace=$MY_OPERATORS_NAMESPACE
local lf_operator_chl=$MY_ASSETREPO_CHL
local lf_strategy="Automatic"
local lf_catalog_source_name="ibm-integration-asset-repository-catalog"
local lf_wait_for_state=true
local lf_csv_name=$MY_ASSETREPO_CASE
decho 3 "create_operator_subscription \"${lf_operator_name}\" \"${lf_operator_namespace}\" \"${lf_operator_chl}\" \"${lf_strategy}\" \"${lf_catalog_source_name}\" \"${lf_wait_for_state}\" \"${lf_csv_name}\""
create_operator_subscription "${lf_operator_name}" "${lf_operator_namespace}" "${lf_operator_chl}" "${lf_strategy}" "${lf_catalog_source_name}" "${lf_wait_for_state}" "${lf_csv_name}"
if $MY_ASSETREPO_INSTANCE; then
#SB]20240612 prise en compte de l'existence ou non de la variable portant la version
if [ -z "$MY_ASSETREPO_VERSION" ]; then
export MY_ASSETREPO_VERSION=$(oc ibm-pak list -o json | jq --arg case "$MY_ASSETREPO_CASE" '.[] | select (.name == $case ) | .latestAppVersion')
decho 3 "MY_ASSETREPO_VERSION=$MY_ASSETREPO_VERSION"
fi
# Creating Asset Repository instance
lf_file="${MY_OPERANDSDIR}AR-Capability.yaml"
lf_ns="${MY_OC_PROJECT}"
lf_path="{.status.phase}"
lf_resource="$MY_ASSETREPO_INSTANCE_NAME"
lf_state="Ready"
lf_type="AssetRepository"
lf_wait_for_state=true
create_operand_instance "${lf_file}" "${lf_ns}" "${lf_path}" "${lf_resource}" "${lf_state}" "${lf_type}" "${lf_wait_for_state}"
fi
fi
decho 3 "F:OUT:install_assetrepo"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
################################################
# Install Integration Assembly
function install_intassembly() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_intassembly"
# Creating Integration Assembly instance
if $MY_INTASSEMBLY; then
mylog info "==== Installing Integration Assembly." 1>&2
lf_file="${MY_OPERANDSDIR}IntegrationAssembly-Capability.yaml"
lf_ns="${MY_OC_PROJECT}"
lf_path="{.status.conditions[0].type}"
lf_resource="$MY_INTASSEMBLY_INSTANCE_NAME"
lf_state="Ready"
lf_type="IntegrationAssembly"
lf_wait_for_state=true
create_operand_instance "${lf_file}" "${lf_ns}" "${lf_path}" "${lf_resource}" "${lf_state}" "${lf_type}" "${lf_wait_for_state}"
fi
decho 3 "F:OUT:install_intassembly"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
################################################
# Install ACE
function install_ace() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_ace"
# ibm-appconnect
if $MY_ACE; then
mylog info "==== Installing ACE." 1>&2
# add catalog sources using ibm_pak plugin
check_add_cs_ibm_pak $MY_ACE_CASE amd64
# Creating ACE operator subscription
local lf_operator_name="$MY_ACE_CASE"
local lf_operator_namespace=$MY_OPERATORS_NAMESPACE
local lf_operator_chl=$MY_ACE_CHL
local lf_strategy="Automatic"
local lf_catalog_source_name="appconnect-operator-catalogsource"
local lf_csv_name=$MY_ACE_CASE
local lf_wait_for_state=true
decho 3 "create_operator_subscription \"${lf_operator_name}\" \"${lf_operator_namespace}\" \"${lf_operator_chl}\" \"${lf_strategy}\" \"${lf_catalog_source_name}\" \"${lf_wait_for_state}\" \"${lf_csv_name}\""
create_operator_subscription "${lf_operator_name}" "${lf_operator_namespace}" "${lf_operator_chl}" "${lf_strategy}" "${lf_catalog_source_name}" "${lf_wait_for_state}" "${lf_csv_name}"
#SB]20240612 prise en compte de l'existence ou non de la variable portant la version
if [ -z "$MY_ACE_VERSION" ]; then
export MY_ACE_VERSION=$(oc ibm-pak list -o json | jq --arg case "$MY_ACE_CASE" '.[] | select (.name == $case ) | .latestAppVersion')
fi
# Creating ACE Switch Server instance (used for callable flows)
lf_file="${MY_OPERANDSDIR}ACE-SwitchServer-Capability.yaml"
lf_ns="${MY_OC_PROJECT}"
lf_path="{.status.conditions[0].type}"
lf_resource="$MY_ACE_SWITCHSERVER_INSTANCE_NAME"
lf_state="Ready"
lf_type="SwitchServer"
lf_wait_for_state=true
create_operand_instance "${lf_file}" "${lf_ns}" "${lf_path}" "${lf_resource}" "${lf_state}" "${lf_type}" "${lf_wait_for_state}"
# Creating ACE Dashboard instance
lf_file="${MY_OPERANDSDIR}ACE-Dashboard-Capability.yaml"
lf_ns="${MY_OC_PROJECT}"
lf_path="{.status.conditions[0].type}"
lf_resource="$MY_ACE_DASHBOARD_INSTANCE_NAME"
lf_state="Ready"
lf_type="Dashboard"
lf_wait_for_state=true
create_operand_instance "${lf_file}" "${lf_ns}" "${lf_path}" "${lf_resource}" "${lf_state}" "${lf_type}" "${lf_wait_for_state}"
# Creating ACE Designer instance
lf_file="${MY_OPERANDSDIR}ACE-Designer-Capability.yaml"
lf_ns="${MY_OC_PROJECT}"
lf_path="{.status.conditions[0].type}"
lf_resource="$MY_ACE_DESIGNER_INSTANCE_NAME"
lf_state="Ready"
lf_type="DesignerAuthoring"
lf_wait_for_state=true
create_operand_instance "${lf_file}" "${lf_ns}" "${lf_path}" "${lf_resource}" "${lf_state}" "${lf_type}" "${lf_wait_for_state}"
fi
decho 3 "F:OUT:install_ace"
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER - $SC_SPACES_INCR))
}
################################################
# Install APIC
function install_apic() {
SC_SPACES_COUNTER=$((SC_SPACES_COUNTER + $SC_SPACES_INCR))
decho 3 "F:IN :install_apic"
# ibm-apiconnect
if $MY_APIC; then
mylog info "==== Installing APIC." 1>&2
# add catalog sources using ibm_pak plugin
check_add_cs_ibm_pak $MY_APIC_CASE amd64
# Creating APIC operator subscription
local lf_operator_name="$MY_APIC_CASE"
local lf_operator_namespace=$MY_OPERATORS_NAMESPACE
local lf_operator_chl=$MY_APIC_CHL
local lf_strategy="Automatic"
local lf_catalog_source_name="ibm-apiconnect-catalog"
local lf_wait_for_state=true
local lf_csv_name=$MY_APIC_CASE
decho 3 "create_operator_subscription \"${lf_operator_name}\" \"${lf_operator_namespace}\" \"${lf_operator_chl}\" \"${lf_strategy}\" \"${lf_catalog_source_name}\" \"${lf_wait_for_state}\" \"${lf_csv_name}\""
create_operator_subscription "${lf_operator_name}" "${lf_operator_namespace}" "${lf_operator_chl}" "${lf_strategy}" "${lf_catalog_source_name}" "${lf_wait_for_state}" "${lf_csv_name}"