Skip to content

Commit 5e38cd4

Browse files
avinalgabemontero
authored andcommitted
add config for enabling tekton results dbssl
- add dbssl for dev_setup - add config for enabling dbssl generally Signed-off-by: Avinal Kumar <[email protected]> rh-pre-commit.version: 2.2.0 rh-pre-commit.check-secrets: ENABLED
1 parent 542db3f commit 5e38cd4

File tree

8 files changed

+94
-5
lines changed

8 files changed

+94
-5
lines changed

developer/openshift/apps/pipeline-service.sh

+43
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,38 @@ 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 -newkey rsa:4096 -nodes -text \
64+
-keyout "$TEKTON_RESULTS_DB_SSL/root.key" \
65+
-out "$TEKTON_RESULTS_DB_SSL/root.csr" \
66+
-subj "/CN=postgres-postgresql.tekton-results.svc.cluster.local" \
67+
-addext "subjectAltName=DNS:postgres-postgresql.tekton-results.svc.cluster.local" \
68+
> /dev/null 2>&1
69+
chmod og-rwx "$TEKTON_RESULTS_DB_SSL/root.key"
70+
openssl x509 -req -days 7 -text \
71+
-signkey "$TEKTON_RESULTS_DB_SSL/root.key" \
72+
-in "$TEKTON_RESULTS_DB_SSL/root.csr" \
73+
-extfile "/etc/ssl/openssl.cnf" \
74+
-extensions v3_ca \
75+
-out "$TEKTON_RESULTS_DB_SSL/ca.crt" \
76+
> /dev/null 2>&1
77+
openssl req -new -nodes -text \
78+
-out "$TEKTON_RESULTS_DB_SSL/root.csr" \
79+
-keyout "$TEKTON_RESULTS_DB_SSL/tls.key" \
80+
-subj "/CN=postgres-postgresql.tekton-results.svc.cluster.local" \
81+
-addext "subjectAltName=DNS:postgres-postgresql.tekton-results.svc.cluster.local" \
82+
> /dev/null 2>&1
83+
chmod og-rwx "$TEKTON_RESULTS_DB_SSL/tls.key"
84+
openssl x509 -req -text -days 7 -CAcreateserial \
85+
-in "$TEKTON_RESULTS_DB_SSL/root.csr" \
86+
-CA "$TEKTON_RESULTS_DB_SSL/ca.crt" \
87+
-CAkey "$TEKTON_RESULTS_DB_SSL/root.key" \
88+
-out "$TEKTON_RESULTS_DB_SSL/tls.crt" \
89+
> /dev/null 2>&1
90+
}
91+
5992
patch_tekton_results_manifests(){
6093
yq --inplace "
6194
.data.[\"db.password\"]=\"$(echo -n "$TEKTON_RESULTS_DATABASE_PASSWORD" | base64)\",
@@ -75,8 +108,18 @@ EOF
75108
yq --inplace "
76109
.data.[\"config.env\"]=\"$string_data\"
77110
" "$WORK_DIR/environment/compute/tekton-results/tekton-results-minio-config.yaml"
111+
yq --inplace "
112+
.data.[\"ca.crt\"]=\"$(base64 "$TEKTON_RESULTS_DB_SSL/ca.crt")\" |
113+
.data.[\"tls.crt\"]=\"$(base64 "$TEKTON_RESULTS_DB_SSL/tls.crt")\" |
114+
.data.[\"tls.key\"]=\"$(base64 "$TEKTON_RESULTS_DB_SSL/tls.key")\"
115+
" "$WORK_DIR/environment/compute/tekton-results/tekton-results-postgresql-tls-secret.yaml"
116+
yq --inplace "
117+
.data.[\"tekton-results-db-ca.pem\"]=\"$(cat "$TEKTON_RESULTS_DB_SSL/tls.crt" "$TEKTON_RESULTS_DB_SSL/ca.crt")\"
118+
" "$WORK_DIR/environment/compute/tekton-results/rds-db-cert-configmap.yaml"
78119
}
79120

121+
122+
80123
deploy_application() {
81124
echo "- Deploy application:"
82125

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

+16-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
@@ -54,6 +64,10 @@ spec:
5464
value: "false"
5565
- name: shmVolume.enabled
5666
value: "false"
67+
# provide CA cert as extraEnv until the issue is resolved. See above ^
68+
extraEnv:
69+
- name: PGSSLROOTCERT
70+
value: /opt/bitnami/postgresql/certs/ca.crt
5771
syncPolicy:
5872
# Comment this out if you want to manually trigger deployments (using the
5973
# Argo CD Web UI or Argo CD CLI), rather than automatically deploying on

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ spec:
1313
- name: api
1414
env:
1515
- name: DB_SSLMODE
16-
value: "disable"
16+
value: "verify-ca"

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)