-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipeline2.yaml
3270 lines (2567 loc) · 134 KB
/
pipeline2.yaml
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
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: cp4i-config
namespace: default
spec:
workspaces:
- name: cp4i-ws
finally:
- name: output-usage
params:
- name: SCRIPT
value: >-
oc delete configmap/pipeline-cp4i-config-output -n default --ignore-not-found=true
oc delete configmap/pipeline-extra-api-gtwy-demo-output -n default --ignore-not-found=true
oc delete configmap/pipeline-apic-ptl-demo-output -n default --ignore-not-found=true
if [[ "$(tasks.setup-workspace.results.output)" = "true" ]]
then
if [[ "$(params.DEPLOY_API_CONNECT_DEMOS)" == "true" ]]; then
if [[ ! -z $(oc get deployment datapower-operator -n openshift-operators --ignore-not-found -o jsonpath='{.metadata.labels.olm\.owner}') ]] &&
[[ ! -z $(oc get deployment ibm-apiconnect -n openshift-operators --ignore-not-found -o jsonpath='{.metadata.labels.olm\.owner}') ]]; then
if [[ ! -z "$(oc get APIConnectCluster apim-demo -n $(params.CP4I_NAMESPACE) --no-headers --ignore-not-found)" ]]; then
API_GTWY_MGR=$(oc get route remote-api-gw-gateway-manager -n cp4i-dp -o jsonpath='{.spec.host}')
API_GTWY_EP=$(oc get route remote-api-gw-gateway -n cp4i-dp -o jsonpath='{.spec.host}')
APIC_PTL_URI=$(oc get portalcluster apim-demo-ptl -n $(params.CP4I_NAMESPACE) -o jsonpath='{.status.endpoints[?(@.name=="portalWeb")].uri}')"cp4i-demo-org/demo"
APIC_CONSUMER_CATALOG_URI=$(oc get managementcluster apim-demo-mgmt -n $(params.CP4I_NAMESPACE) -o jsonpath='{.status.endpoints[?(@.name=="consumerCatalog")].uri}')"cp4i-demo-org/sandbox"
echo "----------------------------"
echo "API Gateway Service info:"
echo
echo "Management Endpoint URL: https://"$API_GTWY_MGR
echo "API Endpoint Base URL: https://"$API_GTWY_EP
echo "----------------------------"
oc create configmap pipeline-extra-api-gtwy-demo-output -n default
oc patch configmap/pipeline-extra-api-gtwy-demo-output -p "{\"data\":{\"msg\":\"Pipeline run completed\",\"mgmt-endpoint-url\":\"https://${API_GTWY_MGR}\",\"api-endpoint-url\":\"https://${API_GTWY_EP}\"}}"
if [[ ! -z "$(params.APIC_API_KEY)" ]]; then
echo "----------------------------"
echo "API Connect Portals CP4I Demo POrg..."
echo
echo "Sandbox Catalog:"
echo " UI URL:" $APIC_CONSUMER_CATALOG_URI
echo
echo "Demo Catalog:"
echo " UI URL:" $APIC_PTL_URI
echo " User name: andre"
echo " User password:" $(params.APPDEV_PWD)
echo "----------------------------"
oc create configmap pipeline-apic-ptl-demo-output -n default
oc patch configmap/pipeline-apic-ptl-demo-output -p "{\"data\":{\"msg\":\"Pipeline CP4I Config run completed\",\"sandbox-portal-url\":\"${APIC_CONSUMER_CATALOG_URI}\",\"demo-portal-url\":\"${APIC_PTL_URI}\",\"demo-portal-username\":\"andre\",\"demo-portal-user-password\":\"$(params.APPDEV_PWD)\"}}"
else
echo "----------------------------"
echo "APIC Demo Portal assets were not configured because API Key was not provided."
echo "----------------------------"
oc create configmap pipeline-apic-ptl-demo-output -n default
oc patch configmap/pipeline-apic-ptl-demo-output -p "{\"data\":{\"msg\":\"Pipeline CP4I Config run completed, but Demo Portal assets were not configured because API Key was not provided.\"}}"
fi
else
echo "----------------------------"
echo "APIC Demo assets were not installed because APIC instance was not deployed."
echo "----------------------------"
oc create configmap pipeline-extra-api-gtwy-demo-output -n default
oc patch configmap/pipeline-extra-api-gtwy-demo-output -p "{\"data\":{\"msg\":\"Pipeline CP4I Config run completed, but Extra API Gateway was not deployed because APIC instance is not available.\"}}"
oc create configmap pipeline-apic-ptl-demo-output -n default
oc patch configmap/pipeline-apic-ptl-demo-output -p "{\"data\":{\"msg\":\"Pipeline CP4I Config run completed, but APIC instance was not configured because APIC instance is not available.\"}}"
fi
else
echo "----------------------------"
echo "APIC Demo assets were not installed because the corresponding Operators are not installed."
echo "----------------------------"
oc create configmap pipeline-extra-api-gtwy-demo-output -n default
oc patch configmap/pipeline-extra-api-gtwy-demo-output -p "{\"data\":{\"msg\":\"Pipeline CP4I Config run completed, but Extra API Gateway was not deployed because Operators are not available.\"}}"
oc create configmap pipeline-apic-ptl-demo-output -n default
oc patch configmap/pipeline-apic-ptl-demo-output -p "{\"data\":{\"msg\":\"Pipeline CP4I Config run completed, but APIC instance was not configured because Operators are not available.\"}}"
fi
else
echo "----------------------------"
echo "APIC Demo assets were not installed per user request."
echo "----------------------------"
oc create configmap pipeline-extra-api-gtwy-demo-output -n default
oc patch configmap/pipeline-extra-api-gtwy-demo-output -p "{\"data\":{\"msg\":\"Pipeline CP4I Config run completed, but Extra API Gateway was not deployed per user request.\"}}"
oc create configmap pipeline-apic-ptl-demo-output -n default
oc patch configmap/pipeline-apic-ptl-demo-output -p "{\"data\":{\"msg\":\"Pipeline CP4I Config run completed, but APIC instance was not configured per user request.\"}}"
fi
else
echo "----------------------------"
echo "Pipeline CP4I Config couldn't run successfully."
echo "Check the logs in setup-workspace task for more details."
echo "----------------------------"
oc create configmap pipeline-cp4i-config-output -n default
oc patch configmap/pipeline-cp4i-config-output -p "{\"data\":{\"msg\":\"Pipeline CP4I Config couldn't run. Check the logs in setup-workspace task for more details.\"}}"
fi
- name: VERSION
value: latest
taskRef:
kind: Task
name: jgr-task-0.2
params:
- name: CP4I_NAMESPACE
default: tools
description: Namespace to deploy Platform UI
type: string
- name: ACE_NAMESPACE
default: tools
description: Namespace to deploy App Connect assets
type: string
- name: ES_NAMESPACE
default: tools
description: Namespace to deploy Event Streams assets
type: string
- name: CP4I_VERSION
default: 16.1.0
description: Version of CP4I Platform UI to deploy
type: string
- name: MQ_VERSION
default: 9.4.0.6-r1
description: Version of MQ to deploy
type: string
- name: ES_VERSION
default: 11.5.1
description: Version of ES for Kafka Connect
type: string
- name: DEPLOY_EVENT_STREAMS_DEMOS
default: 'true'
description: Deploy event streams demo assets
type: string
- name: DEPLOY_API_CONNECT_DEMOS
default: 'true'
description: Deploy apiconnect demo assets
type: string
- name: DEPLOY_EVENT_ENDPOINT_MANAGEMENT_DEMOS
default: 'true'
description: Deploy event endpoint management demo assets
type: string
- name: DEPLOY_MQ_DEMOS
default: 'true'
description: Deploy MQ demo assets
type: string
- name: DEPLOY_ACE_DEMOS
default: 'true'
description: Deploy ACE demo assets
type: string
- name: DP_NAMESPACE
default: cp4i-dp
description: Namespace to deploy Extra API Gateway
type: string
- name: MQ_UNIFORM_CLUSTER_NAMESPACE
default: cp4i
description: Namespace to deploy MQ Uniform Cluster assets
type: string
- name: MAILTRAP_USER
default: ''
description: User to configure mail server
type: string
- name: MAILTRAP_PWD
default: ''
description: Password to configure mail server
type: string
- name: SF_USER
default: ''
description: User to connect to SF
type: string
- name: SF_PWD
default: ''
description: Password to connect to SF
type: string
- name: SF_CLIENT_ID
default: ''
description: Client Id to connect to SF
type: string
- name: SF_CLIENT_SECRET
default: ''
description: Client Secret to connect to SF
type: string
- name: SF_LOGIN_URL
default: ''
description: Login URL to connect to SF
type: string
- name: EEM_APIC_INT
default: 'false'
description: EEM API integration flag
type: string
- name: EA_WATSONX
default: 'false'
description: WatsonX integration flag
type: string
- name: EEM_TOKEN
default: ''
description: Token to access EEM
type: string
- name: APIC_API_KEY
default: ''
description: API Key to access APIC
type: string
- name: APPDEV_PWD
default: ''
description: Password for App Dev Consumer Org Admin
type: string
- name: OCP_BLOCK_STORAGE
default: ocs-storagecluster-ceph-rbd
description: Block Storage Class for Cluster
type: string
- name: OCP_FILE_STORAGE
default: ocs-storagecluster-cephfs
description: File Storage Class for Cluster
type: string
- name: REPO_SIGNATURE
default: 'JGR-20241201-002'
description: CP4I Deployer Helper Repo Signature
type: string
- name: TRACE
default: 'true'
description: Flag to enable trace in scripts
type: string
- name: VERBOSE
default: 'true'
description: Flag to enable verbose output in scripts
type: string
- name: IBM_SECRETS_MANAGER_ENDPOINT
default: >-
https://afa20521-cd75-4864-843f-e59fd0ffd49d.us-south.secrets-manager.appdomain.cloud
type: string
- name: IBM_ENTITLEMENT_KEY_ID
default: a65ac528-bbca-1425-8d07-fde9e2f1ff70
type: string
tasks:
- name: setup-workspace
params:
- name: SCRIPT
value: >-
set -o xtrace
echo "Setting up workspace for pipeline"
cd workspace/cp4i-ws
git clone --single-branch --branch main https://github.com/gomezrjo/cp4i-deployer-helper.git
echo "Checking helper repo."
if grep -q "$(params.REPO_SIGNATURE)" cp4i-deployer-helper/signature; then
echo "Valid signature in helper repo."
else
echo "Helper repo is out of sync, update this repo."
printf false | tee $(results.output.path)
exit 0
fi
echo "Checking SC provided in parameter OCP_BLOCK_STORAGE"
SC_EXIST=$(oc get sc --no-headers | awk -v sc_name=$(params.OCP_BLOCK_STORAGE) '$1 == sc_name {print "yes"}')
if [[ -z $SC_EXIST ]]; then
echo "SC does NOT exist"
printf false | tee $(results.output.path)
exit 0
else
echo "SC found"
fi
echo "Checking SC provided in parameter OCP_FILE_STORAGE"
SC_EXIST=$(oc get sc --no-headers | awk -v sc_name=$(params.OCP_FILE_STORAGE) '$1 == sc_name {print "yes"}')
if [[ -z $SC_EXIST ]]; then
echo "SC does NOT exist"
printf false | tee $(results.output.path)
exit 0
else
echo "SC found"
fi
printf true | tee $(results.output.path)
tar -xvzf cp4i-deployer-helper/extras/toolkit-linux.tgz
chmod +x apic
git clone --single-branch --branch main https://github.com/gomezrjo/cp4i-ace-artifacts.git
echo "Workspace for pipeline is ready"
- name: VERSION
value: latest
retries: 3
taskRef:
kind: Task
name: jgr-task-0.2
timeout: 3h0m0s
workspaces:
- name: cp4i-ws
- name: setup-image-registry
params:
- name: SCRIPT
value: >-
set -o xtrace
echo "Setting up Image Registry if needed"
cd workspace/cp4i-ws
echo "Preparing pvc.yaml file"
cat <<EOF >pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: image-registry-storage
namespace: openshift-image-registry
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Gi
EOF
if [[ -z "$(oc get pod -n openshift-image-registry -l docker-registry=default --ignore-not-found --no-headers)" ]]; then
echo "Image Registry instance is NOT available"
if [[ "$(oc get clusteroperator image-registry --ignore-not-found --no-headers | awk '{print $3}')" == "True" ]]; then
echo "Image Registry operator is available"
echo "Patching Image Registry configuration"
oc patch configs.imageregistry.operator.openshift.io/cluster --type merge -p '{"spec":{"managementState":"Managed"}}'
oc patch config.imageregistry.operator.openshift.io/cluster --type=merge -p '{"spec":{"rolloutStrategy":"Recreate","replicas":1}}'
echo "Creating PVC for Image Registry"
oc create -f pvc.yaml -n openshift-image-registry
oc patch configs.imageregistry.operator.openshift.io/cluster --type merge -p '{"spec":{"storage":{"pvc":{"claim":"image-registry-storage"}}}}'
while ! oc wait --for=jsonpath='{.status.conditions[1].status}'=True deployment/image-registry -n openshift-image-registry 2>/dev/null; do sleep 30; done
echo "Image Registry instance is deployed"
else
echo "Image Registry operator is NOT available"
fi
else
echo "Image Registry instance is available"
fi
echo "Image Registry is ready"
- name: VERSION
value: latest
runAfter:
- setup-workspace
retries: 3
taskRef:
kind: Task
name: jgr-task-0.2
timeout: 3h0m0s
workspaces:
- name: cp4i-ws
- name: create-extra-namespaces
params:
- name: SCRIPT
value: |-
set -o xtrace
CP4I_NAMESPACES=($(params.DP_NAMESPACE) $(params.MQ_UNIFORM_CLUSTER_NAMESPACE))
for NS in "${CP4I_NAMESPACES[@]}"
do
echo "Creating a new namespace called" $NS
if [[ -z "$(oc projects -q | awk -v ns=$NS '$1 == ns {print $1}')" ]]; then
oc new-project $NS
else
echo "Namespace" $NS "already exists."
fi
done
echo "Namespaces are ready"
- name: VERSION
value: latest
runAfter:
- setup-image-registry
taskRef:
kind: Task
name: jgr-task-0.2
when:
- input: "$(tasks.setup-workspace.results.output)"
operator: in
values: ["true"]
- name: get-entitlement-key
params:
- name: KEY_ID
value: $(params.IBM_ENTITLEMENT_KEY_ID)
- name: SECRETS_MANAGER_ENDPOINT_URL
value: $(params.IBM_SECRETS_MANAGER_ENDPOINT)
runAfter:
- create-extra-namespaces
taskRef:
kind: Task
name: ibmcloud-secrets-manager-get
when:
- input: "$(tasks.setup-workspace.results.output)"
operator: in
values: ["true"]
- name: create-ibm-entitlement-key
params:
- name: SCRIPT
value: >-
set -o xtrace
CP4I_NAMESPACES=($(params.DP_NAMESPACE) $(params.MQ_UNIFORM_CLUSTER_NAMESPACE))
for NS in "${CP4I_NAMESPACES[@]}"
do
if oc get secret ibm-entitlement-key -n $NS >/dev/null 2>&1; then
username=$(oc get secret ibm-entitlement-key -n $NS -o jsonpath='{.data.\.dockerconfigjson}' | base64 -d | jq -r '.auths."cp.icr.io".username')
password=$(oc get secret ibm-entitlement-key -n $NS -o jsonpath='{.data.\.dockerconfigjson}' | base64 -d | jq -r '.auths."cp.icr.io".password')
if [[ "$username" == "cp" ]] && [[ "$password" == "$(tasks.get-entitlement-key.results.secret-value)" ]]; then
echo "Secret ibm-entitlement-key was already created. Skipping secret creation"
else
echo "Existing ibm-entitlement-key password does not match retrieved key. Deleting..."
oc delete secret ibm-entitlement-key -n $NS --ignore-not-found=true
echo "Creating new ibm-entitlement-key secret"
oc create secret docker-registry ibm-entitlement-key \
--docker-username=cp \
--docker-password=$(tasks.get-entitlement-key.results.secret-value) \
--docker-server=cp.icr.io \
--namespace=$NS
fi
else
echo "Creating new ibm-entitlement-key secret"
oc create secret docker-registry ibm-entitlement-key \
--docker-username=cp \
--docker-password=$(tasks.get-entitlement-key.results.secret-value) \
--docker-server=cp.icr.io \
--namespace=$NS
fi
done
- name: VERSION
value: latest
runAfter:
- get-entitlement-key
taskRef:
kind: Task
name: jgr-task-0.2
when:
- input: "$(tasks.setup-workspace.results.output)"
operator: in
values: ["true"]
- name: event-streams-instance-configuration
params:
- name: SCRIPT
value: >-
set -o xtrace
echo "Checking if Event Streams operator is available."
if [[ -z $(oc get deployment eventstreams-cluster-operator -n openshift-operators --ignore-not-found -o jsonpath='{.metadata.labels.olm\.owner}') ]]; then
echo "Skipping Event Streams instance configuration, Operator was not installed."
exit 0
fi
if [[ -z "$(oc get eventstreams es-demo -n $(params.ES_NAMESPACE) --no-headers --ignore-not-found)" ]]; then
echo "Skipping Event Streams instance configuration, Instance was not deployed."
exit 0
fi
cd workspace/cp4i-ws/cp4i-deployer-helper
echo "Configuring event streams instance"
echo "Adding topics and users"
oc apply -f resources/02a-es-initial-config-jgr-topics.yaml -n
$(params.CP4I_NAMESPACE)
oc apply -f resources/02a-es-initial-config-jgr-users.yaml -n
$(params.CP4I_NAMESPACE)
oc apply -f resources/02a-es-initial-config-ea-topics.yaml -n
$(params.CP4I_NAMESPACE)
oc apply -f resources/02a-es-initial-config-watsonx-topics.yaml -n
$(params.CP4I_NAMESPACE)
echo "Topcis and users are created"
echo "Event streams instance is configured"
- name: VERSION
value: latest
runAfter:
- create-ibm-entitlement-key
taskRef:
kind: Task
name: jgr-task-0.2
when:
- input: "$(tasks.setup-workspace.results.output)"
operator: in
values: ["true"]
- input: "$(params.DEPLOY_EVENT_STREAMS_DEMOS)"
operator: in
values: ["true"]
workspaces:
- name: cp4i-ws
- name: kafka-connect-instances-deployment
params:
- name: SCRIPT
value: >-
set -o xtrace
if [[ -z $(oc get deployment eventstreams-cluster-operator -n openshift-operators --ignore-not-found -o jsonpath='{.metadata.labels.olm\.owner}') ]]; then
echo "Skipping Kafka Connect instance deployment, Operator was not installed."
exit 0
fi
if [[ -z "$(oc get eventstreams es-demo -n $(params.ES_NAMESPACE) --no-headers --ignore-not-found)" ]]; then
echo "Skipping Kafka Connect instance deployment, Instance was not deployed."
exit 0
fi
cd workspace/cp4i-ws/cp4i-deployer-helper
echo "Deploying kafka connect instance"
ES_INST_NAME='es-demo'
ES_BOOTSTRAP_SERVER=$(oc get eventstreams ${ES_INST_NAME} -n $(params.ES_NAMESPACE) -o=jsonpath='{range .status.kafkaListeners[*]}{.name} {.bootstrapServers}{"\n"}{end}' | awk '$1=="authsslsvc" {print $2}')
echo "Updating template with Bootsrap info..."
( echo "cat <<EOF" ; cat templates/template-es-kafka-connect.yaml ;) | \
ES_BOOTSTRAP_SERVER=${ES_BOOTSTRAP_SERVER} \
ES_VERSION=$(params.ES_VERSION) \
sh > es-kafka-connect.yaml
echo "Creating Kafka Connect instance..."
oc apply -f es-kafka-connect.yaml
echo "Waiting for Kafka Connect instance to be deployed..."
while ! oc wait --for=jsonpath='{.status.conditions[0].type}'=Ready
kafkaconnects/jgr-connect-cluster -n
$(params.ES_NAMESPACE) 2>/dev/null; do sleep 30; done
echo "Updating template with Bootsrap info..."
( echo "cat <<EOF" ; cat templates/template-es-kafka-connect-watsonx.yaml ;) | \
ES_BOOTSTRAP_SERVER=${ES_BOOTSTRAP_SERVER} \
ES_VERSION=$(params.ES_VERSION) \
sh > es-kafka-connect-watsonx.yaml
echo "Creating Kafka Connect instance..."
oc apply -f es-kafka-connect-watsonx.yaml
echo "Waiting for Kafka Connect instance to be deployed..."
while ! oc wait --for=jsonpath='{.status.conditions[0].type}'=Ready
kafkaconnects/watsonx-demo-sources -n
$(params.ES_NAMESPACE) 2>/dev/null; do sleep 30; done
echo "Kafka connect instance is ready"
- name: VERSION
value: latest
runAfter:
- event-streams-instance-configuration
taskRef:
kind: Task
name: jgr-task-0.2
when:
- input: "$(tasks.setup-workspace.results.output)"
operator: in
values: ["true"]
- input: "$(params.DEPLOY_EVENT_STREAMS_DEMOS)"
operator: in
values: ["true"]
workspaces:
- name: cp4i-ws
- name: kafka-connectors-deployment
params:
- name: SCRIPT
value: >-
set -o xtrace
if [[ -z $(oc get deployment eventstreams-cluster-operator -n openshift-operators --ignore-not-found -o jsonpath='{.metadata.labels.olm\.owner}') ]]; then
echo "Skipping Kafka Connectors deployment, Operator was not installed."
exit 0
fi
if [[ -z "$(oc get eventstreams es-demo -n $(params.ES_NAMESPACE) --no-headers --ignore-not-found)" ]]; then
echo "Skipping Kafka Connectors deployment, Instance was not deployed."
exit 0
fi
cd workspace/cp4i-ws/cp4i-deployer-helper
echo "Deploying datagen kafka connectors"
ES_INST_NAME='es-demo'
echo "Configuring datagen kafka connectors ..."
echo "Getting configuration information..."
ES_USER_PWD=$(oc get secret kafka-connect-user -n $(params.ES_NAMESPACE) -o jsonpath='{.data.password}' | base64 -d)
ES_CERT_PWD=$(oc get secret ${ES_INST_NAME}-cluster-ca-cert -n $(params.ES_NAMESPACE) -o=jsonpath='{.data.ca\.password}' | base64 -d)
ES_SCHEMA_REGISTRY_URL=$(oc get eventstreams ${ES_INST_NAME} -n $(params.ES_NAMESPACE) -o=jsonpath='{range .status.endpoints[*]}{.name} {.uri}{"\n"}{end}' | awk '$1=="apicurioregistry" {print $2}')
echo "Updating template with config info..."
( echo "cat <<EOF" ; cat templates/template-es-kafka-connector-datagen.yaml ;) | \
ES_USER_PWD=${ES_USER_PWD} \
ES_CERT_PWD=${ES_CERT_PWD} \
ES_SCHEMA_REGISTRY_URL=${ES_SCHEMA_REGISTRY_URL} \
sh > es-kafka-connector-datagen.yaml
echo "Creating datagen kafka connectors..."
oc apply -f es-kafka-connector-datagen.yaml
echo "Waiting for kafka connector to be ready..."
while ! oc wait --for=jsonpath='{.status.conditions[0].type}'=Ready
kafkaconnector/kafka-datagen -n
$(params.ES_NAMESPACE) 2>/dev/null; do sleep 30; done
echo "Waiting for kafka connector to be ready..."
while ! oc wait --for=jsonpath='{.status.conditions[0].type}'=Ready
kafkaconnector/kafka-datagen-avro -n
$(params.ES_NAMESPACE) 2>/dev/null; do sleep 30; done
echo "Waiting for kafka connector to be ready..."
while ! oc wait --for=jsonpath='{.status.conditions[0].type}'=Ready
kafkaconnector/kafka-datagen-reg -n
$(params.ES_NAMESPACE) 2>/dev/null; do sleep 30; done
echo "DataGen kafka connectors are ready"
- name: VERSION
value: latest
runAfter:
- kafka-connect-instances-deployment
taskRef:
kind: Task
name: jgr-task-0.2
when:
- input: "$(tasks.setup-workspace.results.output)"
operator: in
values: ["true"]
- input: "$(params.DEPLOY_EVENT_STREAMS_DEMOS)"
operator: in
values: ["true"]
workspaces:
- name: cp4i-ws
- name: kafka-bridge-instance-deployment
params:
- name: SCRIPT
value: >-
set -o xtrace
if [[ -z $(oc get deployment eventstreams-cluster-operator -n openshift-operators --ignore-not-found -o jsonpath='{.metadata.labels.olm\.owner}') ]]; then
echo "Skipping Kafka Bridge instance configuration, Operator was not installed."
exit 0
fi
if [[ -z "$(oc get eventstreams es-demo -n $(params.ES_NAMESPACE) --no-headers --ignore-not-found)" ]]; then
echo "Skipping Kafka Bridge instance configuration, Instance was not deployed."
exit 0
fi
cd workspace/cp4i-ws/cp4i-deployer-helper
echo "Deploying kafka bridge instance"
ES_INST_NAME='es-demo'
ES_BOOTSTRAP_SERVER=$(oc get eventstreams ${ES_INST_NAME} -n $(params.ES_NAMESPACE) -o=jsonpath='{range .status.kafkaListeners[*]}{.name} {.bootstrapServers}{"\n"}{end}' | awk '$1=="external" {print $2}')
echo "Updating template with bootsrap info..."
( echo "cat <<EOF" ; cat templates/template-es-kafka-bridge.yaml ;) | \
ES_BOOTSTRAP_SERVER=${ES_BOOTSTRAP_SERVER} \
sh > es-kafka-bridge.yaml
echo "Creating kafka bridge instance..."
oc apply -f es-kafka-bridge.yaml
echo "Waiting for kafka bridge instance to be deployed..."
while ! oc wait --for=jsonpath='{.status.conditions[0].type}'=Ready
kafkabridge/jgr-es-demo-bridge -n
$(params.ES_NAMESPACE) 2>/dev/null; do sleep 30; done
echo "Creating route for kafka bridge instance..."
oc apply -f resources/02d-es-kafka-bridge-route.yaml
echo "Kafka bridge instance is ready"
- name: VERSION
value: latest
runAfter:
- kafka-connectors-deployment
taskRef:
kind: Task
name: jgr-task-0.2
when:
- input: "$(tasks.setup-workspace.results.output)"
operator: in
values: ["true"]
- input: "$(params.DEPLOY_EVENT_STREAMS_DEMOS)"
operator: in
values: ["true"]
workspaces:
- name: cp4i-ws
- name: apic-analytics-offload-configuration
params:
- name: SCRIPT
value: >-
set -o xtrace
if [[ -z $(oc get deployment eventstreams-cluster-operator -n openshift-operators --ignore-not-found -o jsonpath='{.metadata.labels.olm\.owner}') ]]; then
echo "Skipping APIC Analytics offload configuration, Operator was not installed."
exit 0
fi
if [[ -z "$(oc get eventstreams es-demo -n $(params.ES_NAMESPACE) --no-headers --ignore-not-found)" ]]; then
echo "Skipping APIC Analytics offload configuration, Instance was not deployed."
exit 0
fi
if [[ -z $(oc get deployment datapower-operator -n openshift-operators --ignore-not-found -o jsonpath='{.metadata.labels.olm\.owner}') ]]; then
echo "Skipping APIC Analytics offload configuration, Operator was not installed."
exit 0
fi
if [[ -z $(oc get deployment ibm-apiconnect -n openshift-operators --ignore-not-found -o jsonpath='{.metadata.labels.olm\.owner}') ]]; then
echo "Skipping APIC Analytics offload configuration, Operator was not installed."
exit 0
fi
if [[ -z "$(oc get APIConnectCluster apim-demo -n $(params.CP4I_NAMESPACE) --no-headers --ignore-not-found)" ]]; then
echo "Skipping APIC Analytics offload configuration, Instance was not deployed."
exit 0
fi
cd workspace/cp4i-ws/cp4i-deployer-helper
echo "Creating Kafka configuration for APIC Analytics offloading"
APIC_INST_NAME='apim-demo'
ES_INST_NAME='es-demo'
ES_USER_ID='apic-analytics-offload-user'
TRUSTSTORE_PWD=$(oc get secret ${ES_INST_NAME}-cluster-ca-cert -n $(params.ES_NAMESPACE) -o=jsonpath='{.data.ca\.password}' | base64 -d)
oc extract secret/${ES_INST_NAME}-cluster-ca-cert -n $(params.ES_NAMESPACE) --keys=ca.p12
keytool -importkeystore -srckeystore ca.p12 -srcstoretype PKCS12 -destkeystore es-cert.jks -deststoretype JKS -srcstorepass ${TRUSTSTORE_PWD} -deststorepass ${TRUSTSTORE_PWD} -srcalias ca.crt -destalias ca.crt -noprompt
echo "Creating Kafka TrustStore Cert..."
if [[ -z "$(oc get secret apim-demo-offload-a7s-certificate -n $(params.CP4I_NAMESPACE) --no-headers --ignore-not-found)" ]]; then
oc create secret generic apim-demo-offload-a7s-certificate -n $(params.CP4I_NAMESPACE) --from-file=es-cert.jks=./es-cert.jks
else
echo "Secret already exists."
fi
( echo "cat <<EOF" ; cat templates/template-apic-offload-kafka-secret.yaml ;) | \
TRUSTSTORE_PWD=${TRUSTSTORE_PWD} \
sh > apic-offload-kafka-secret.yaml
echo "Creating Kafka TrustStore Secret..."
oc apply -f apic-offload-kafka-secret.yaml -n $(params.CP4I_NAMESPACE)
echo "Preparing patch file for Analytics..."
ES_BOOTSTRAP_SERVER=$(oc get eventstreams ${ES_INST_NAME} -n $(params.ES_NAMESPACE) -o=jsonpath='{.status.kafkaListeners[?(@.name=="external")].bootstrapServers}')
ES_USER_PWD=$(oc get secret ${ES_USER_ID} -n $(params.ES_NAMESPACE) -o=jsonpath='{.data.password}' | base64 -d)
( echo "cat <<EOF" ; cat templates/template-apic-offload-kafka-scram.yaml ;) | \
ES_BOOTSTRAP_SERVER=${ES_BOOTSTRAP_SERVER} \
ES_USER_PWD=${ES_USER_PWD} \
sh > apic-offload-kafka-scram.yaml
oc patch apiconnectcluster ${APIC_INST_NAME} -n $(params.CP4I_NAMESPACE) --type merge --patch-file apic-offload-kafka-scram.yaml
rm -f ca.p12
echo "APIC Analytics Offload with Kafka configuration has been created."
- name: VERSION
value: latest
runAfter:
- kafka-bridge-instance-deployment
taskRef:
kind: Task
name: jgr-task-0.2
when:
- input: "$(tasks.setup-workspace.results.output)"
operator: in
values: ["true"]
- input: "$(params.DEPLOY_EVENT_STREAMS_DEMOS)"
operator: in
values: ["true"]
- input: "$(params.DEPLOY_API_CONNECT_DEMOS)"
operator: in
values: ["true"]
workspaces:
- name: cp4i-ws
- name: eem-populate-catalog
params:
- name: SCRIPT
value: >-
set -o xtrace
if [[ -z $(oc get deployment ibm-eem-operator -n openshift-operators --ignore-not-found -o jsonpath='{.metadata.labels.olm\.owner}') ]]; then
echo "Skipping EEM instance configuration, Operator was not installed."
exit 0
fi
if [[ -z "$(oc get eventendpointmanagement eem-demo-mgr -n $(params.CP4I_NAMESPACE) --no-headers --ignore-not-found)" ]]; then
echo "Skipping EEM instance configuration, Instance was not deployed."
exit 0
fi
if [[ -z $(oc get deployment eventstreams-cluster-operator -n openshift-operators --ignore-not-found -o jsonpath='{.metadata.labels.olm\.owner}') ]]; then
echo "Skipping EEM instance configuration, Operator was not installed."
exit 0
fi
if [[ -z "$(oc get eventstreams es-demo -n $(params.ES_NAMESPACE) --no-headers --ignore-not-found)" ]]; then
echo "Skipping EEM instance configuration, Instance was not deployed."
exit 0
fi
cd workspace/cp4i-ws/cp4i-deployer-helper
echo "Event Endpoint Manager Configuration..."
EEM_INST_NAME='eem-demo-mgr'
ES_INST_NAME='es-demo'
EEM_API=$(oc get route -n $(params.CP4I_NAMESPACE) ${EEM_INST_NAME}-ibm-eem-admin -ojsonpath='https://{.spec.host}')
ES_BOOTSTRAP_SERVER=$(oc get eventstreams ${ES_INST_NAME} -n $(params.ES_NAMESPACE) -o=jsonpath='{range .status.kafkaListeners[*]}{.name} {.bootstrapServers}{"\n"}{end}' | awk '$1=="authsslsvc" {print $2}')
ES_BOOTSTRAP_SERVER=$(echo ${ES_BOOTSTRAP_SERVER%:*})
oc extract secret/${ES_INST_NAME}-cluster-ca-cert -n $(params.ES_NAMESPACE) --keys=ca.crt
ES_CERTIFICATE=$(awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' ca.crt)
ES_PASSWORD=$(oc get secret eem-user -n $(params.ES_NAMESPACE) -ojsonpath='{.data.password}' | base64 -d)
( echo "cat <<EOF" ; cat templates/template-eem-es-cluster.json ;) | \
ES_BOOTSTRAP_SERVER=${ES_BOOTSTRAP_SERVER} \
ES_CERTIFICATE=${ES_CERTIFICATE} \
ES_PASSWORD=${ES_PASSWORD} \
sh > eem-es-cluster.json
echo "Checking if ES Cluster exists..."
curl -X GET -s -k \
--dump-header eem-api-header \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $(params.EEM_TOKEN)" \
--output eem-response-data.json \
--write-out '%{response_code}' \
$EEM_API/eem/clusters
clusterId=$(jq 'map(select(.name=="es-demo")) | .[] .id' eem-response-data.json)
if [[ -z $clusterId ]]; then
echo "Cluster does NOT exist."
echo "Creating ES Cluster reference in EEM..."
curl -X POST -s -k \
--dump-header eem-api-header \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $(params.EEM_TOKEN)" \
--data @eem-es-cluster.json \
--output eem-response-data.json \
--write-out '%{response_code}' \
$EEM_API/eem/clusters
clusterId=$(jq .id eem-response-data.json)
else
echo "Cluster does exist."
echo "ClusterID = " $clusterId
fi
topics=("CANCELLATIONS" "CUSTOMERS.NEW" "DOOR.BADGEIN" "ORDERS.ONLINE" "ORDERS.NEW" "STOCK.NOSTOCK" "SENSOR.READINGS" "STOCK.MOVEMENT" "PRODUCT.RETURNS" "PRODUCT.REVIEWS" "cp4i-es-demo-topic")
for topic in "${topics[@]}"
do
echo "Checking if Topic already exists..."
curl -X GET -s -k \
--dump-header eem-api-header \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $(params.EEM_TOKEN)" \
--output eem-response-data.json \
--write-out '%{response_code}' \
$EEM_API/eem/eventsources
topicName=$(jq -r '.topic.name' templates/template-eem-eventsource-$topic.json)
eventSourceId=$(jq --arg topicName "$topicName" 'map(select(.topic.name==$topicName)) | .[] .id' eem-response-data.json)
if [[ -z $eventSourceId ]]; then
echo "Event Source does NOT exist"
echo "Creating Topic..." $topicName
curl -X POST -s -k \
--dump-header eem-api-header \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $(params.EEM_TOKEN)" \
--data "$(cat templates/template-eem-eventsource-$topic.json | jq ".clusterId |= ${clusterId}")" \
--output eem-response-data.json \
--write-out '%{response_code}' \
$EEM_API/eem/eventsources
eventSourceId=$(jq .id eem-response-data.json)
else
echo "Event Source does exist"
echo "EventSourceID = " $eventSourceId
fi
echo "Checking if Option already exists..."
curl -X GET -s -k \
--dump-header eem-api-header \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $(params.EEM_TOKEN)" \
--output eem-response-data.json \
--write-out '%{response_code}' \
$EEM_API/eem/options
optionName=$(jq -r '.alias' templates/template-eem-option-$topic.json)
asyncapiOptionId=$(jq -r --arg optionName "$optionName" 'map(select(.alias==$optionName)) | .[] .id' eem-response-data.json)
if [[ -z $asyncapiOptionId ]]; then
echo "Option does NOT exist"
echo "Creating Option..." $optionName
curl -X POST -s -k \
--dump-header eem-api-header \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $(params.EEM_TOKEN)" \
--data "$(cat templates/template-eem-option-$topic.json | jq ".eventSourceId |= ${eventSourceId}")" \
--output eem-response-data.json \
--write-out '%{response_code}' \
$EEM_API/eem/options
asyncapiOptionId=$(jq -r .id eem-response-data.json)
else
echo "Option does exist"
echo "AsyncAPIOptionID = " $asyncapiOptionId
fi
if [[ "$(params.EEM_APIC_INT)" == "true" ]]; then
echo "Getting AsyncAPI for APIC..."
curl -X GET -s -k \
--dump-header eem-api-header \
-H 'Accept: application/yaml' \