Skip to content

Commit c002396

Browse files
committed
Reapply "add config for enabling tekton results dbssl"
This reverts commit 9177668 plus some tweaks to use `verify-full` TLS verification.
1 parent 4f3cc8b commit c002396

File tree

10 files changed

+88
-22
lines changed

10 files changed

+88
-22
lines changed

developer/openshift/apps/pipeline-service.sh

+42
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ configure_argocd_apps(){
3030
setup_tekton_results() {
3131
echo -n "- Tekton Results: "
3232
get_tekton_results_credentials
33+
generate_tekton_results_db_ssl_cert
3334
patch_tekton_results_manifests
3435
echo "OK"
3536
}
@@ -56,6 +57,37 @@ EOF
5657
TEKTON_RESULTS_S3_PASSWORD="$(yq ".s3_password" "$tekton_results_credentials")"
5758
}
5859

60+
generate_tekton_results_db_ssl_cert(){
61+
TEKTON_RESULTS_DB_SSL="$WORK_DIR/certificates/tekton-results"
62+
mkdir -p "$TEKTON_RESULTS_DB_SSL"
63+
openssl req -new -nodes -text \
64+
-subj "/CN=cluster.local" \
65+
-out "$TEKTON_RESULTS_DB_SSL/root.csr" \
66+
-keyout "$TEKTON_RESULTS_DB_SSL/root.key" \
67+
> /dev/null
68+
chmod og-rwx "$TEKTON_RESULTS_DB_SSL/root.key"
69+
openssl x509 -req -text -days 7 -extensions v3_ca \
70+
-in "$TEKTON_RESULTS_DB_SSL/root.csr" \
71+
-extfile /etc/ssl/openssl.cnf \
72+
-signkey "$TEKTON_RESULTS_DB_SSL/root.key" \
73+
-out "$TEKTON_RESULTS_DB_SSL/root.crt" \
74+
> /dev/null
75+
openssl req -new -nodes -text \
76+
-subj "/CN=postgres-postgresql.tekton-results.svc.cluster.local" \
77+
-addext "subjectAltName = DNS:postgres-postgresql.tekton-results.svc.cluster.local" \
78+
-out "$TEKTON_RESULTS_DB_SSL/server.csr" \
79+
-keyout "$TEKTON_RESULTS_DB_SSL/server.key" \
80+
> /dev/null
81+
chmod og-rwx "$TEKTON_RESULTS_DB_SSL/server.key"
82+
openssl x509 -req -text -days 7 -CAcreateserial \
83+
-extfile <(printf "subjectAltName=DNS:postgres-postgresql.tekton-results.svc.cluster.local") \
84+
-in "$TEKTON_RESULTS_DB_SSL/server.csr" \
85+
-CA "$TEKTON_RESULTS_DB_SSL/root.crt" \
86+
-CAkey "$TEKTON_RESULTS_DB_SSL/root.key" \
87+
-out "$TEKTON_RESULTS_DB_SSL/server.crt" \
88+
> /dev/null
89+
}
90+
5991
patch_tekton_results_manifests(){
6092
yq --inplace "
6193
.data.[\"db.password\"]=\"$(echo -n "$TEKTON_RESULTS_DATABASE_PASSWORD" | base64)\",
@@ -75,8 +107,18 @@ EOF
75107
yq --inplace "
76108
.data.[\"config.env\"]=\"$string_data\"
77109
" "$WORK_DIR/environment/compute/tekton-results/tekton-results-minio-config.yaml"
110+
yq --inplace "
111+
.data.[\"ca.crt\"]=\"$(base64 "$TEKTON_RESULTS_DB_SSL/root.crt")\" |
112+
.data.[\"tls.crt\"]=\"$(base64 "$TEKTON_RESULTS_DB_SSL/server.crt")\" |
113+
.data.[\"tls.key\"]=\"$(base64 "$TEKTON_RESULTS_DB_SSL/server.key")\"
114+
" "$WORK_DIR/environment/compute/tekton-results/tekton-results-postgresql-tls-secret.yaml"
115+
yq --inplace "
116+
.data.[\"tekton-results-db-ca.pem\"]=\"$(cat "$TEKTON_RESULTS_DB_SSL/root.crt")\"
117+
" "$WORK_DIR/environment/compute/tekton-results/rds-db-cert-configmap.yaml"
78118
}
79119

120+
121+
80122
deploy_application() {
81123
echo "- Deploy application:"
82124

developer/openshift/gitops/argocd/pipeline-service-storage/postgres.yaml

+12-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,18 @@ spec:
2222
value: 13.14.0
2323
- name: tls.enabled
2424
value: "true"
25-
- name: tls.autoGenerated
26-
value: "true"
25+
- name: tls.certificatesSecret
26+
value: "postgresql-tls"
27+
- name: tls.certFilename
28+
value: "tls.crt"
29+
- name: tls.certKeyFilename
30+
value: "tls.key"
31+
# There is an unresolved issue with CA cert that stops pods from
32+
# starting due to readiness probe failure. The workaround is
33+
# discussed here along with the linked issues:
34+
# https://github.com/bitnami/charts/issues/8026
35+
# - name: tls.certCAFilename
36+
# value: "ca.crt"
2737
- name: auth.database
2838
value: "tekton_results"
2939
- name: auth.username

developer/openshift/gitops/argocd/pipeline-service/kustomization.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ resources:
88
patches:
99
- path: tekton-results/minio-create-bucket.yaml
1010
- path: tekton-results/minio-tls.yaml
11-
- path: tekton-results/postgres.yaml
1211

1312
# Skip applying the Tekton operands while the Tekton operator is being installed.
1413
# See more information about this option, here:

developer/openshift/gitops/argocd/pipeline-service/tekton-results/kustomization.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ resources:
77
patches:
88
- path: minio-create-bucket.yaml
99
- path: minio-tls.yaml
10-
- path: postgres.yaml

developer/openshift/gitops/argocd/pipeline-service/tekton-results/postgres.yaml

-16
This file was deleted.

developer/openshift/gitops/local/tekton-results/kustomization.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ resources:
66
- tekton-results-db-secret.yaml
77
- tekton-results-s3-secret.yaml
88
- tekton-results-minio-config.yaml
9+
- rds-db-cert-configmap.yaml
10+
- tekton-results-postgresql-tls-secret.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: rds-root-crt
6+
namespace: tekton-results
7+
data:
8+
# contents of the public certificate should be inserted here
9+
# the name of the key must be same as provided in the tekton results .env config
10+
tekton-results-db-ca.pem:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: postgresql-tls
6+
namespace: tekton-results
7+
data:
8+
# Provide CA, TLS cert and key. CA cert is not being used until readiness
9+
# probe issue is resolved with the binami/postgresql chart
10+
ca.crt:
11+
tls.crt:
12+
tls.key:

operator/gitops/argocd/pipeline-service/tekton-results/api-db-config.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,11 @@ spec:
3333
secretKeyRef:
3434
name: tekton-results-database
3535
key: db.name
36+
volumeMounts:
37+
- name: db-tls-ca
38+
mountPath: /etc/tls/db
39+
readOnly: true
40+
volumes:
41+
- name: db-tls-ca
42+
configMap:
43+
name: rds-root-crt

operator/gitops/argocd/pipeline-service/tekton-results/config.env

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ DB_PASSWORD=
33
DB_HOST=
44
DB_PORT=5432
55
DB_NAME=
6-
DB_SSLMODE=disable
7-
DB_SSLROOTCERT=
6+
DB_SSLMODE=verify-full
7+
DB_SSLROOTCERT=/etc/tls/db/tekton-results-db-ca.pem
88
DB_ENABLE_AUTO_MIGRATION=true
99
SERVER_PORT=8080
1010
PROMETHEUS_PORT=9090

0 commit comments

Comments
 (0)