-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathintegration-test-eaas.yaml
More file actions
1112 lines (1014 loc) · 36.3 KB
/
Copy pathintegration-test-eaas.yaml
File metadata and controls
1112 lines (1014 loc) · 36.3 KB
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/v1
kind: Pipeline
metadata:
name: cts-integration-test-eaas
spec:
description: |
Integration test for CTS using Konflux EaaS (Environment as a Service).
Clones the repository, provisions an ephemeral namespace, and deploys
CTS with PostgreSQL for testing.
params:
- name: SNAPSHOT
description: JSON string representing the snapshot under test
type: string
tasks:
- name: parse-snapshot
taskSpec:
params:
- name: SNAPSHOT
type: string
results:
- name: image-url
description: Container image URL to test
- name: ldap-server-image-url
description: Container image URL for the pre-built LDAP server
- name: ldap-server-present
description: Whether the ldap-server component is present in the Snapshot
- name: git-url
description: Git repository URL
- name: git-revision
description: Git revision (commit SHA)
steps:
- name: extract-metadata
image: quay.io/konflux-ci/appstudio-utils:latest
script: |
#!/usr/bin/env bash
set -euo pipefail
echo "Parsing snapshot..."
SNAPSHOT='$(params.SNAPSHOT)'
# Extract image URL
IMAGE_URL=$(echo "$SNAPSHOT" | jq -r '.components[] | select(.name=="cts") | .containerImage')
echo -n "$IMAGE_URL" | tee $(results.image-url.path)
echo ""
echo "Image to test: $IMAGE_URL"
# Extract ldap-server image URL. If the ldap-server component is absent
# from the Snapshot (e.g. no ldap-server build was triggered for this PR
# because no relevant files changed, and no stable build exists yet), set
# ldap-server-present to "false" so the test pipeline is skipped rather
# than trying to pull a non-existent image.
LDAP_SERVER_IMAGE_URL=$(echo "$SNAPSHOT" | jq -r '(.components[] | select(.name=="ldap-server") | .containerImage) // empty')
if [ -z "$LDAP_SERVER_IMAGE_URL" ]; then
echo "ldap-server not found in Snapshot; skipping integration test"
echo -n "" | tee $(results.ldap-server-image-url.path)
echo -n "false" | tee $(results.ldap-server-present.path)
else
echo -n "$LDAP_SERVER_IMAGE_URL" | tee $(results.ldap-server-image-url.path)
echo -n "true" | tee $(results.ldap-server-present.path)
fi
echo ""
echo "LDAP server image: $LDAP_SERVER_IMAGE_URL"
echo ""
# Extract git repository URL
GIT_URL=$(echo "$SNAPSHOT" | jq -r '.components[] | select(.name=="cts") | .source.git.url')
echo -n "$GIT_URL" | tee $(results.git-url.path)
echo ""
echo "Git URL: $GIT_URL"
# Extract git revision
GIT_REVISION=$(echo "$SNAPSHOT" | jq -r '.components[] | select(.name=="cts") | .source.git.revision')
echo -n "$GIT_REVISION" | tee $(results.git-revision.path)
echo ""
echo "Git revision: $GIT_REVISION"
params:
- name: SNAPSHOT
value: $(params.SNAPSHOT)
- name: provision-environment
runAfter:
- parse-snapshot
when:
- input: $(tasks.parse-snapshot.results.ldap-server-present)
operator: in
values:
- "true"
taskRef:
params:
- name: name
value: eaas-provision-space
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-eaas-provision-space:0.1
- name: kind
value: task
resolver: bundles
params:
- name: ownerKind
value: PipelineRun
- name: ownerName
value: $(context.pipelineRun.name)
- name: ownerUid
value: $(context.pipelineRun.uid)
- name: deploy-openldap
runAfter:
- provision-environment
when:
- input: $(tasks.parse-snapshot.results.ldap-server-present)
operator: in
values:
- "true"
taskSpec:
params:
- name: kubeconfig-secret
type: string
- name: ldap-server-image
type: string
steps:
- name: create-openldap
image: quay.io/konflux-ci/appstudio-utils:latest
script: |
#!/usr/bin/env bash
set -euo pipefail
KUBECONFIG=/tmp/kubeconfig
kubectl get secret $(params.kubeconfig-secret) -o jsonpath='{.data.kubeconfig}' | base64 -d > $KUBECONFIG
export KUBECONFIG
echo "=========================================="
echo "Deploying LDAP Server (pre-built image)"
echo "=========================================="
LDAP_IMAGE="$(params.ldap-server-image)"
echo "Using LDAP server image: $LDAP_IMAGE"
kubectl apply -f - <<EOFYAML
apiVersion: apps/v1
kind: Deployment
metadata:
name: openldap
labels:
app: openldap
spec:
replicas: 1
selector:
matchLabels:
app: openldap
template:
metadata:
labels:
app: openldap
spec:
containers:
- name: openldap
image: $LDAP_IMAGE
ports:
- containerPort: 1389
name: ldap
readinessProbe:
tcpSocket:
port: 1389
initialDelaySeconds: 15
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 12
resources:
requests:
memory: "128Mi"
cpu: "50m"
limits:
memory: "256Mi"
cpu: "200m"
---
apiVersion: v1
kind: Service
metadata:
name: openldap
labels:
app: openldap
spec:
ports:
- port: 1389
targetPort: 1389
name: ldap
selector:
app: openldap
EOFYAML
echo "Waiting for LDAP server to be ready..."
if ! kubectl wait --for=condition=available --timeout=180s deployment/openldap; then
echo "LDAP deployment failed! Debug info:"
kubectl describe deployment openldap
kubectl describe pod -l app=openldap
kubectl logs -l app=openldap --tail=50 || echo "No logs available"
exit 1
fi
echo "✓ LDAP server is ready"
params:
- name: kubeconfig-secret
value: $(tasks.provision-environment.results.secretRef)
- name: ldap-server-image
value: $(tasks.parse-snapshot.results.ldap-server-image-url)
- name: deploy-dex
runAfter:
- provision-environment
when:
- input: $(tasks.parse-snapshot.results.ldap-server-present)
operator: in
values:
- "true"
taskSpec:
params:
- name: kubeconfig-secret
type: string
steps:
- name: create-dex
image: quay.io/konflux-ci/appstudio-utils:latest
script: |
#!/usr/bin/env bash
set -euo pipefail
KUBECONFIG=/tmp/kubeconfig
kubectl get secret $(params.kubeconfig-secret) -o jsonpath='{.data.kubeconfig}' | base64 -d > $KUBECONFIG
export KUBECONFIG
echo "=========================================="
echo "Generating Dex TLS certificate"
echo "=========================================="
# Generate a self-signed CA and Dex server certificate (SAN: DNS:dex)
# so that OIDCOAuthVerifyJwksUri can use https://dex:5556/keys
TMPDIR=$(mktemp -d)
# Generate CA key and cert
openssl genrsa -out "$TMPDIR/ca.key" 4096 2>/dev/null
openssl req -x509 -new -nodes -key "$TMPDIR/ca.key" \
-sha256 -days 365 \
-subj "/CN=dex-test-ca" \
-out "$TMPDIR/ca.crt" 2>/dev/null
# Generate Dex server key and CSR
openssl genrsa -out "$TMPDIR/dex.key" 4096 2>/dev/null
openssl req -new -key "$TMPDIR/dex.key" \
-subj "/CN=dex" \
-out "$TMPDIR/dex.csr" 2>/dev/null
# Sign the Dex cert with the CA, adding SAN for DNS:dex
cat > "$TMPDIR/dex.ext" <<'EXTEOF'
[SAN]
subjectAltName=DNS:dex
EXTEOF
openssl x509 -req -in "$TMPDIR/dex.csr" \
-CA "$TMPDIR/ca.crt" -CAkey "$TMPDIR/ca.key" -CAcreateserial \
-out "$TMPDIR/dex.crt" -days 365 -sha256 \
-extfile "$TMPDIR/dex.ext" -extensions SAN 2>/dev/null
# Store CA cert and Dex TLS cert/key in Kubernetes Secrets
kubectl create secret generic dex-tls \
--from-file=tls.crt="$TMPDIR/dex.crt" \
--from-file=tls.key="$TMPDIR/dex.key"
kubectl create secret generic dex-ca \
--from-file=ca.crt="$TMPDIR/ca.crt"
rm -rf "$TMPDIR"
echo "✓ Dex TLS certificate generated"
echo "=========================================="
echo "Deploying Dex OIDC Provider"
echo "=========================================="
kubectl apply -f - <<'EOFYAML'
apiVersion: v1
kind: ConfigMap
metadata:
name: dex-config
data:
config.yaml: |
issuer: https://dex:5556
storage:
type: memory
web:
https: 0.0.0.0:5556
tlsCert: /etc/dex/tls/tls.crt
tlsKey: /etc/dex/tls/tls.key
logger:
level: debug
enablePasswordDB: true
staticPasswords:
- email: builder@example.com
hash: "$2y$10$6cZyh42YBb2Q5.fE9nj3mu3UHs21NUmVP2fpU63EM3/ecJuHVscEC"
username: builder
userID: "builder"
- email: readonly@example.com
hash: "$2y$10$6cZyh42YBb2Q5.fE9nj3mu3UHs21NUmVP2fpU63EM3/ecJuHVscEC"
username: readonly
userID: "readonly"
staticClients:
- id: cts-integration
secret: cts-integration-secret
name: CTS Integration
redirectURIs:
- http://cts:8080/redirect_uri
grantTypes:
- password
- authorization_code
oauth2:
skipApprovalScreen: true
passwordConnector: local
EOFYAML
kubectl apply -f - <<'EOFYAML'
apiVersion: apps/v1
kind: Deployment
metadata:
name: dex
labels:
app: dex
spec:
replicas: 1
selector:
matchLabels:
app: dex
template:
metadata:
labels:
app: dex
spec:
containers:
- name: dex
image: ghcr.io/dexidp/dex:v2.41.1
args: ["dex", "serve", "/etc/dex/config.yaml"]
ports:
- containerPort: 5556
name: https
resources:
requests:
memory: "64Mi"
cpu: "50m"
limits:
memory: "256Mi"
cpu: "500m"
readinessProbe:
httpGet:
path: /.well-known/openid-configuration
port: 5556
scheme: HTTPS
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 5
failureThreshold: 12
volumeMounts:
- name: dex-config
mountPath: /etc/dex
readOnly: true
- name: dex-tls
mountPath: /etc/dex/tls
readOnly: true
volumes:
- name: dex-config
configMap:
name: dex-config
- name: dex-tls
secret:
secretName: dex-tls
---
apiVersion: v1
kind: Service
metadata:
name: dex
labels:
app: dex
spec:
ports:
- port: 5556
targetPort: 5556
name: https
selector:
app: dex
EOFYAML
echo "Waiting for Dex to be ready..."
if ! kubectl wait --for=condition=available --timeout=180s deployment/dex; then
echo "Dex deployment failed! Debug info:"
kubectl describe deployment dex
kubectl describe pod -l app=dex
kubectl logs -l app=dex --tail=50 || echo "No logs available"
exit 1
fi
echo "✓ Dex is ready"
params:
- name: kubeconfig-secret
value: $(tasks.provision-environment.results.secretRef)
- name: deploy-kafka
runAfter:
- provision-environment
taskSpec:
params:
- name: kubeconfig-secret
type: string
steps:
- name: create-kafka
image: quay.io/konflux-ci/appstudio-utils:latest
script: |
#!/usr/bin/env bash
set -euo pipefail
KUBECONFIG=/tmp/kubeconfig
kubectl get secret $(params.kubeconfig-secret) -o jsonpath='{.data.kubeconfig}' | base64 -d > $KUBECONFIG
export KUBECONFIG
echo "=========================================="
echo "Deploying Kafka (Apache KRaft single-node)"
echo "=========================================="
kubectl apply -f - <<'EOFYAML'
apiVersion: apps/v1
kind: Deployment
metadata:
name: kafka
labels:
app: kafka
spec:
replicas: 1
selector:
matchLabels:
app: kafka
template:
metadata:
labels:
app: kafka
spec:
initContainers:
- name: copy-kafka-config
image: docker.io/apache/kafka:3.9.2
command: ["/bin/sh", "-c", "cp -r /opt/kafka/config/. /mnt/kafka-config/"]
volumeMounts:
- name: kafka-config
mountPath: /mnt/kafka-config
containers:
- name: kafka
image: docker.io/apache/kafka:3.9.2
ports:
- containerPort: 9092
name: client
- containerPort: 9093
name: controller
env:
- name: KAFKA_NODE_ID
value: "1"
- name: KAFKA_PROCESS_ROLES
value: "broker,controller"
- name: KAFKA_CONTROLLER_QUORUM_VOTERS
value: "1@localhost:9093"
- name: KAFKA_LISTENERS
value: "PLAINTEXT://:9092,CONTROLLER://:9093"
- name: KAFKA_ADVERTISED_LISTENERS
value: "PLAINTEXT://kafka:9092"
- name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
value: "CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT"
- name: KAFKA_CONTROLLER_LISTENER_NAMES
value: "CONTROLLER"
- name: KAFKA_AUTO_CREATE_TOPICS_ENABLE
value: "true"
- name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
value: "1"
- name: KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR
value: "1"
- name: KAFKA_TRANSACTION_STATE_LOG_MIN_ISR
value: "1"
- name: KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS
value: "0"
resources:
requests:
memory: "256Mi"
cpu: "100m"
limits:
memory: "512Mi"
cpu: "500m"
readinessProbe:
tcpSocket:
port: 9092
initialDelaySeconds: 20
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 24
volumeMounts:
- name: kafka-config
mountPath: /opt/kafka/config
- name: kafka-logs
mountPath: /tmp/kafka-logs
- name: kafka-gc-logs
mountPath: /opt/kafka/logs
volumes:
- name: kafka-config
emptyDir: {}
- name: kafka-logs
emptyDir: {}
- name: kafka-gc-logs
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: kafka
labels:
app: kafka
spec:
ports:
- port: 9092
targetPort: 9092
name: client
- port: 9093
targetPort: 9093
name: controller
selector:
app: kafka
EOFYAML
echo "Waiting for Kafka to be ready..."
if ! kubectl wait --for=condition=available --timeout=300s deployment/kafka; then
echo "Kafka deployment failed! Debug info:"
kubectl describe deployment kafka
kubectl describe pod -l app=kafka
kubectl logs -l app=kafka --tail=50 || echo "No logs available"
exit 1
fi
echo "✓ Kafka is ready"
params:
- name: kubeconfig-secret
value: $(tasks.provision-environment.results.secretRef)
- name: deploy-database
runAfter:
- provision-environment
when:
- input: $(tasks.parse-snapshot.results.ldap-server-present)
operator: in
values:
- "true"
taskSpec:
params:
- name: kubeconfig-secret
type: string
steps:
- name: create-database
image: quay.io/konflux-ci/appstudio-utils:latest
script: |
#!/usr/bin/env bash
set -euo pipefail
# Get kubeconfig from secret
KUBECONFIG=/tmp/kubeconfig
kubectl get secret $(params.kubeconfig-secret) -o jsonpath='{.data.kubeconfig}' | base64 -d > $KUBECONFIG
export KUBECONFIG
echo "=========================================="
echo "Deploying PostgreSQL Database"
echo "=========================================="
# Deploy PostgreSQL
kubectl apply -f - <<EOF
apiVersion: v1
kind: Service
metadata:
name: cts-db
labels:
app: cts-db
spec:
ports:
- port: 5432
targetPort: 5432
selector:
app: cts-db
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: cts-db
labels:
app: cts-db
spec:
replicas: 1
selector:
matchLabels:
app: cts-db
template:
metadata:
labels:
app: cts-db
spec:
containers:
- name: postgresql
image: postgres:13-alpine
env:
- name: POSTGRES_DB
value: cts
- name: POSTGRES_USER
value: cts
- name: POSTGRES_PASSWORD
value: cts-test
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
ports:
- containerPort: 5432
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "500m"
readinessProbe:
exec:
command:
- pg_isready
- -U
- cts
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 5
failureThreshold: 6
volumeMounts:
- name: postgres-data
mountPath: /var/lib/postgresql/data
volumes:
- name: postgres-data
emptyDir: {}
EOF
echo "Waiting for database to be ready..."
# Check pod status first
echo ""
echo "Pod status:"
kubectl get pods -l app=cts-db
echo ""
echo "Deployment status:"
kubectl get deployment cts-db
# Wait with more detailed output on failure
if ! kubectl wait --for=condition=available --timeout=180s deployment/cts-db; then
echo ""
echo "=========================================="
echo "Database deployment failed! Debug info:"
echo "=========================================="
echo ""
echo "Deployment details:"
kubectl describe deployment cts-db
echo ""
echo "Pod details:"
kubectl describe pod -l app=cts-db
echo ""
echo "Pod logs (if available):"
kubectl logs -l app=cts-db --tail=100 || echo "No logs available"
echo ""
echo "Events:"
kubectl get events --sort-by='.lastTimestamp'
exit 1
fi
echo "✓ Database is ready"
params:
- name: kubeconfig-secret
value: $(tasks.provision-environment.results.secretRef)
- name: deploy-cts
runAfter:
- deploy-database
- deploy-openldap
- deploy-dex
- deploy-kafka
when:
- input: $(tasks.parse-snapshot.results.ldap-server-present)
operator: in
values:
- "true"
taskSpec:
params:
- name: kubeconfig-secret
type: string
- name: image-url
type: string
steps:
- name: create-service
image: quay.io/konflux-ci/appstudio-utils:latest
script: |
#!/usr/bin/env bash
set -euo pipefail
# Get kubeconfig from secret
KUBECONFIG=/tmp/kubeconfig
kubectl get secret $(params.kubeconfig-secret) -o jsonpath='{.data.kubeconfig}' | base64 -d > $KUBECONFIG
export KUBECONFIG
IMAGE="$(params.image-url)"
echo "=========================================="
echo "Deploying CTS Service"
echo "=========================================="
echo "Image: $IMAGE"
# Create ConfigMap with production configuration and httpd config for CTS
kubectl apply -f - <<'EOFYAML'
apiVersion: v1
kind: ConfigMap
metadata:
name: cts-config
data:
config.py: |
from conf.config import BaseConfiguration
class ProdConfiguration(BaseConfiguration):
AUTH_BACKEND = "oidc_or_kerberos"
SQLALCHEMY_DATABASE_URI = "postgresql://cts:cts-test@cts-db:5432/cts"
AUTH_OPENIDC_USERINFO_URI = "https://dex:5556/userinfo"
AUTH_OPENIDC_REQUIRED_SCOPES = ["openid"]
AUTH_LDAP_SERVER = "ldap://openldap:1389"
AUTH_LDAP_GROUPS = [
("ou=groups,dc=example,dc=com", "(&(objectClass=posixGroup)(memberUid={0}))"),
]
ADMINS = {"groups": [], "users": ["builder@example.com"]}
ALLOWED_BUILDERS = {"groups": [], "users": ["builder@example.com"]}
MESSAGING_BACKEND = "kafka"
MESSAGING_BROKER_URLS = ["kafka:9092"]
MESSAGING_KAFKA_SECURITY_PROTOCOL = "PLAINTEXT"
MESSAGING_KAFKA_SASL_MECHANISM = ""
MESSAGING_KAFKA_USERNAME = ""
MESSAGING_KAFKA_PASSWORD = ""
MESSAGING_KAFKA_COMPRESSION_TYPE = "none"
MESSAGING_TOPIC_PREFIX = "cts."
httpd.conf: |
ServerRoot "/etc/httpd"
PidFile /tmp/httpd.pid
Listen 0.0.0.0:8080 http
User apache
Group apache
DocumentRoot "/var/www/html"
ErrorLog /dev/stderr
TransferLog /dev/stdout
LogLevel warn
TypesConfig /etc/mime.types
DefaultRuntimeDir /tmp
Include conf.modules.d/*.conf
OIDCProviderMetadataURL https://dex:5556/.well-known/openid-configuration
OIDCClientID cts-integration
OIDCClientSecret cts-integration-secret
OIDCRedirectURI http://cts:8080/redirect_uri
OIDCCryptoPassphrase changeme
OIDCRemoteUserClaim preferred_username
OIDCCABundlePath /etc/dex-ca/ca.crt
OIDCOAuthVerifyJwksUri https://dex:5556/keys
OIDCOAuthRemoteUserClaim email
OIDCUnAuthAction pass
WSGISocketPrefix /tmp/wsgi
WSGIDaemonProcess cts threads=5 home=/usr/share/cts
WSGIScriptAlias / /usr/share/cts/cts.wsgi
<Directory /usr/share/cts>
WSGIProcessGroup cts
WSGIApplicationGroup %{GLOBAL}
<If "%{HTTP:Authorization} =~ /^Bearer/">
AuthType auth-openidc
# Dex access tokens do not include a scope claim in the JWT payload.
# Inject it here so load_openidc_user's validate_scopes() check passes.
# Scoped to Bearer requests only so that Kerberos requests (which lack
# OIDC_ environ variables) are still routed to load_krb_user_from_request
# by load_oidc_or_krb_user_from_request instead of always hitting the
# OIDC branch.
SetEnv OIDC_CLAIM_scope "openid email"
</If>
<Else>
AuthType openid-connect
</Else>
<RequireAny>
<RequireAll>
Require expr %{REQUEST_URI} !~ /userinfo/
Require method GET
</RequireAll>
Require valid-user
</RequireAny>
</Directory>
EOFYAML
# Deploy CTS
kubectl apply -f - <<EOF
apiVersion: v1
kind: Service
metadata:
name: cts
labels:
app: cts
spec:
ports:
- port: 8080
targetPort: 8080
name: http
selector:
app: cts
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: cts
labels:
app: cts
spec:
replicas: 1
selector:
matchLabels:
app: cts
template:
metadata:
labels:
app: cts
spec:
initContainers:
- name: run-migrations
image: $IMAGE
command:
- /bin/bash
- -c
- |
set -e
echo "Running database migrations..."
cd /src
cts-manager db upgrade
echo "Migrations completed successfully"
volumeMounts:
- name: cts-config
mountPath: /etc/cts
readOnly: true
containers:
- name: cts
image: $IMAGE
command:
- /bin/bash
- -c
- |
set -e
exec httpd -DFOREGROUND -f /etc/cts/httpd.conf
ports:
- containerPort: 8080
env:
- name: REQUESTS_CA_BUNDLE
value: /etc/dex-ca/ca.crt
resources:
requests:
memory: "256Mi"
cpu: "200m"
limits:
memory: "512Mi"
cpu: "1000m"
readinessProbe:
httpGet:
path: /api/1/
port: 8080
initialDelaySeconds: 15
periodSeconds: 5
timeoutSeconds: 5
failureThreshold: 12
livenessProbe:
httpGet:
path: /api/1/
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
volumeMounts:
- name: cts-config
mountPath: /etc/cts
readOnly: true
- name: dex-ca
mountPath: /etc/dex-ca
readOnly: true
volumes:
- name: cts-config
configMap:
name: cts-config
- name: dex-ca
secret:
secretName: dex-ca
EOF
echo "Waiting for CTS service to be ready..."
# Check pod status first
echo ""
echo "Pod status:"
kubectl get pods -l app=cts
echo ""
echo "Deployment status:"
kubectl get deployment cts
# Wait with more detailed output on failure
if ! kubectl wait --for=condition=available --timeout=300s deployment/cts; then
echo ""
echo "=========================================="
echo "CTS deployment failed! Debug info:"
echo "=========================================="
echo ""
echo "Deployment details:"
kubectl describe deployment cts
echo ""
echo "Pod details:"
kubectl describe pod -l app=cts
echo ""
echo "CTS Pod logs (if available):"
kubectl logs -l app=cts --tail=100 || echo "No logs available"
echo ""
echo "Database pod status (for reference):"
kubectl get pod -l app=cts-db
echo ""
echo "Events:"
kubectl get events --sort-by='.lastTimestamp' | tail -30
exit 1
fi
echo ""
echo "✓ CTS service is ready"
params:
- name: kubeconfig-secret
value: $(tasks.provision-environment.results.secretRef)
- name: image-url
value: $(tasks.parse-snapshot.results.image-url)
- name: run-tests
runAfter:
- deploy-cts
when:
- input: $(tasks.parse-snapshot.results.ldap-server-present)
operator: in
values:
- "true"
taskSpec:
params:
- name: kubeconfig-secret
type: string
- name: git-url
type: string
- name: git-revision
type: string
results:
- name: test-result
description: Test execution result
steps:
- name: execute-tests
image: quay.io/konflux-ci/appstudio-utils:latest
script: |
#!/usr/bin/env bash
set -euo pipefail
echo "=========================================="
echo "Running Integration Tests"
echo "=========================================="
# Get kubeconfig
KUBECONFIG=/tmp/kubeconfig
kubectl get secret $(params.kubeconfig-secret) -o jsonpath='{.data.kubeconfig}' | base64 -d > $KUBECONFIG
export KUBECONFIG
# Get the namespace
NAMESPACE=$(kubectl config view --minify -o jsonpath='{..namespace}')
echo "Ephemeral namespace: $NAMESPACE"
echo ""
echo "Creating test runner pod in namespace: $NAMESPACE"
# Retrieve the Dex CA cert so the test runner pod can trust Dex over HTTPS
DEX_CA_B64=$(kubectl get secret dex-ca -o jsonpath='{.data.ca\.crt}')
# Create a test runner pod in the target namespace (using appstudio-utils which has git and python)