Skip to content

Commit

Permalink
feat(kubernetes): support external database URLs (#1365)
Browse files Browse the repository at this point in the history
  • Loading branch information
theosanderson authored Mar 17, 2024
1 parent 20cab57 commit c239d03
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
13 changes: 13 additions & 0 deletions kubernetes/loculus/templates/externaldb-sealed-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.externalDatabase.urlSealedSecret }}
apiVersion: bitnami.com/v1alpha1
kind: SealedSecret
metadata:
name: externaldb-credentials
annotations:
sealedsecrets.bitnami.com/cluster-wide: "true"
spec:
encryptedData:
url: {{ .Values.externalDatabase.urlSealedSecret | quote }}
username: {{ .Values.externalDatabase.usernameSealedSecret | quote }}
password: {{ .Values.externalDatabase.passwordSealedSecret | quote }}
{{ end }}
5 changes: 4 additions & 1 deletion kubernetes/loculus/templates/loculus-database-service.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{{- if not .Values.externalDatabaseUrl }}
apiVersion: v1
kind: Service
metadata:
name: loculus-database-service
spec:

{{- template "loculus.serviceType"}}
selector:
app: loculus
Expand All @@ -14,4 +16,5 @@ spec:
nodePort: 30432
{{- end }}
protocol: TCP
name: http
name: http
{{- end }}
39 changes: 36 additions & 3 deletions kubernetes/loculus/templates/loculus-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,51 @@ spec:
ports:
- containerPort: 8079
args:
- "--spring.datasource.url=jdbc:postgresql://localhost:5432/loculus"
- "--spring.datasource.username=postgres"
- "--spring.datasource.password=unsecure"
- "--spring.datasource.url=$(DB_URL)"
- "--spring.datasource.username=$(DB_USERNAME)"
- "--spring.datasource.password=$(DB_PASSWORD)"
- "--keycloak.user=backend"
- "--keycloak.password=backend"
- "--keycloak.realm=loculus"
- "--keycloak.client=test-cli"
- "--keycloak.url=http://loculus-keycloak-service:8083"
- "--spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://loculus-keycloak-service:8083/realms/loculus/protocol/openid-connect/certs"
env:
{{- if .Values.externalDatabase.urlSealedSecret }}
- name: DB_URL
valueFrom:
secretKeyRef:
name: externaldb-credentials
key: url
{{- else }}
- name: DB_URL
value: "jdbc:postgresql://localhost:5432/loculus"
{{- end }}
{{- if .Values.externalDatabase.usernameSealedSecret }}
- name: DB_USERNAME
valueFrom:
secretKeyRef:
name: externaldb-credentials
key: username
{{- else }}
- name: DB_USERNAME
value: "postgres"
{{- end }}
{{- if .Values.externalDatabase.passwordSealedSecret }}
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: externaldb-credentials
key: password
{{- else }}
- name: DB_PASSWORD
value: "password"
{{- end }}
volumeMounts:
- name: loculus-backend-config-processed
mountPath: /config
{{- end }}
{{- if not .Values.externalDatabaseUrl }}
- name: database
image: postgres:latest
ports:
Expand All @@ -93,6 +125,7 @@ spec:
value: "unsecure"
- name: POSTGRES_DB
value: "loculus"
{{- end }}

imagePullSecrets:
- name: ghcr-secret
Expand Down
6 changes: 5 additions & 1 deletion kubernetes/loculus/values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
environment: server
externalDatabase:
urlSealedSecret: ""
usernameSealedSecret: ""
passwordSealedSecret: ""
disableWebsite: false
disableBackend: false
disablePreprocessing: false
Expand Down Expand Up @@ -198,4 +202,4 @@ auth:
from: "noreply@loculus.org"
envelopeFrom: "noreply@loculus.org"
verifyEmail: true
resetPasswordAllowed: true
resetPasswordAllowed: true

0 comments on commit c239d03

Please sign in to comment.