Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add correct CA cert to JDBC #324

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions controllers/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ func (r *TrustyAIServiceReconciler) createDeploymentObject(ctx context.Context,
}

if instance.Spec.Storage.IsStorageDatabase() {
_, err := r.getSecret(ctx, instance.Name+"-db-tls", instance.Namespace)
_, err := r.getSecret(ctx, instance.Name+"-db-ca", instance.Namespace)
if err != nil {
deploymentConfig.UseDBTLSCerts = false
log.FromContext(ctx).Info("Using insecure database connection. Certificates " + instance.Name + "-db-tls not found")
log.FromContext(ctx).Info("Using insecure database connection. Certificates " + instance.Name + "-db-ca not found")
} else {
deploymentConfig.UseDBTLSCerts = true
log.FromContext(ctx).Info("Using secure database connection with certificates " + instance.Name + "-db-tls")
log.FromContext(ctx).Info("Using secure database connection with certificates " + instance.Name + "-db-ca")
}
} else {
deploymentConfig.UseDBTLSCerts = false
Expand Down
8 changes: 4 additions & 4 deletions controllers/templates/service/deployment.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ spec:
key: databaseName
- name: QUARKUS_DATASOURCE_JDBC_URL
{{ if .UseDBTLSCerts }}
value: "jdbc:${QUARKUS_DATASOURCE_DB_KIND}://${DATABASE_SERVICE}:${DATABASE_PORT}/${DATABASE_NAME}?sslMode=verify-ca&serverSslCert=/etc/tls/db/tls.crt"
value: "jdbc:${QUARKUS_DATASOURCE_DB_KIND}://${DATABASE_SERVICE}:${DATABASE_PORT}/${DATABASE_NAME}?sslMode=verify-ca&serverSslCert=/etc/tls/db/ca.crt"
{{ else }}
value: "jdbc:${QUARKUS_DATASOURCE_DB_KIND}://${DATABASE_SERVICE}:${DATABASE_PORT}/${DATABASE_NAME}"
{{ end }}
Expand Down Expand Up @@ -146,7 +146,7 @@ spec:
readOnly: false
{{ end }}
{{ if .UseDBTLSCerts }}
- name: db-tls-certs
- name: db-ca-cert
mountPath: /etc/tls/db
readOnly: true
{{ end }}
Expand Down Expand Up @@ -238,8 +238,8 @@ spec:
secretName: {{ .Instance.Name }}-internal
defaultMode: 420
{{ if .UseDBTLSCerts }}
- name: db-tls-certs
- name: db-ca-cert
secret:
secretName: {{ .Instance.Name }}-db-tls
secretName: {{ .Instance.Name }}-db-ca
defaultMode: 420
{{ end }}
Loading