From 57564aa713a27ea694c5ee242014475eeeb9b1d9 Mon Sep 17 00:00:00 2001 From: Alex Pietrow Date: Tue, 13 Aug 2024 15:46:48 +1000 Subject: [PATCH] Allow mongodb SSL and srv configs --- deploy/helm/templates/api-service/secrets.yaml | 6 ++++-- deploy/helm/values.yaml | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/deploy/helm/templates/api-service/secrets.yaml b/deploy/helm/templates/api-service/secrets.yaml index b7076a1bdb..eecbe91bae 100644 --- a/deploy/helm/templates/api-service/secrets.yaml +++ b/deploy/helm/templates/api-service/secrets.yaml @@ -1,6 +1,8 @@ {{- $nameSpace := include "lowcoder.namespace" . -}} {{- $mongoUser := (and .Values.mongodb.auth.usernames (first .Values.mongodb.auth.usernames)) | default "" -}} {{- $mongoPassword := (and .Values.mongodb.auth.passwords (first .Values.mongodb.auth.passwords)) | default "" -}} +{{- $mongoProtocol := ternary "mongodb+srv" "mongodb" .Values.mongodb.useSrv -}} +{{- $mongoSSL := ternary "true" "false" .Values.mongodb.useSSL -}} {{- $lowcoderDatabase := first .Values.mongodb.auth.databases -}} {{- $mongoSecret := lookup "v1" "Secret" $nameSpace .Values.mongodb.auth.existingSecret | default dict -}} {{- $mongoSecretPassword := (index ($mongoSecret.data | default dict) "password" | default "" | b64dec) -}} @@ -20,9 +22,9 @@ metadata: {{- end }} stringData: {{- if .Values.mongodb.enabled }} - LOWCODER_MONGODB_URL: "mongodb://{{ $mongoUser }}:{{ $mongoPassword }}@{{ $mongoServicename }}.{{ $nameSpace }}.svc.cluster.local/{{ $lowcoderDatabase }}?retryWrites=true&ssl=false" + LOWCODER_MONGODB_URL: "{{ $mongoProtocol }}://{{ $mongoUser }}:{{ $mongoPassword }}@{{ $mongoServicename }}.{{ $nameSpace }}.svc.cluster.local/{{ $lowcoderDatabase }}?retryWrites=true&ssl=false" {{- else }} - LOWCODER_MONGODB_URL: "mongodb://{{ $mongoUser }}:{{ $mongoSecretPassword }}@{{ $externalUrl }}/{{ $lowcoderDatabase }}?retryWrites=true&ssl=false" + LOWCODER_MONGODB_URL: "{{ $mongoProtocol }}://{{ $mongoUser }}:{{ $mongoSecretPassword }}@{{ $externalUrl }}/{{ $lowcoderDatabase }}?retryWrites=true&ssl={{ $mongoSSL }}" {{- end }} LOWCODER_DB_ENCRYPTION_PASSWORD: {{ .Values.global.config.encryption.password | default "lowcoder.org" | quote }} LOWCODER_DB_ENCRYPTION_SALT: {{ .Values.global.config.encryption.salt | default "lowcoder.org" | quote }} diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yaml index 915456bcec..52375f00f1 100644 --- a/deploy/helm/values.yaml +++ b/deploy/helm/values.yaml @@ -63,10 +63,14 @@ redis: # Find out more about configuration options at: https://github.com/bitnami/charts/tree/main/bitnami/mongodb/#parameters # mongodb: - #externalUrl: enabled: true service: nameOverride: lowcoder-mongodb + #externalUrl: + # if set to true, will use mongodb+srv:// as a prefix in mongo connection string + useSrv: false + # if set to true, will use SSL in mongo connection string; Only considered if using external mongodb + useSSL: false auth: rootUser: root rootPassword: secret