Skip to content

Commit 9e9b73d

Browse files
authored
add postgresql.existingHost & existingSecret for backend's SECRETKEY (#18)
* feat(postgresql/existingSecret): add an existingSecret for the SECRETKEY and allow setting an existingHost for the database Signed-off-by: Toni Tauro <toni.tauro@adfinis.com> * fix(values): lint Signed-off-by: Toni Tauro <toni.tauro@adfinis.com> --------- Signed-off-by: Toni Tauro <toni.tauro@adfinis.com>
1 parent 451c9b4 commit 9e9b73d

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

charts/caluma/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type: application
77
# This is the chart version. This version number should be incremented each time you make changes
88
# to the chart and its templates, including the app version.
99
# Versions are expected to follow Semantic Versioning (https://semver.org/)
10-
version: 0.10.8
10+
version: 0.11.0
1111

1212
# This is the version number of the application being deployed. This version number should be
1313
# incremented each time you make changes to the application. Versions are not expected to

charts/caluma/templates/backend-deployment.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,16 @@ spec:
2727
imagePullPolicy: {{ .Values.image.backend.pullPolicy }}
2828
env:
2929
- name: DATABASE_HOST
30+
{{- if and .Values.postgresql.enabled .Values.backend.postgresql.existingHost }}
31+
{{ fail "postgresql.enabled and backend.postgresql.existingHost are mutually exclusive, please pick one" }}
32+
{{- end }}
33+
{{- if .Values.postgresql.enabled }}
3034
value: "{{ template "caluma.fullname" . }}-postgresql"
35+
{{- else if .Values.backend.postgresql.existingHost }}
36+
value: {{ .Values.backend.postgresql.existingHost | quote }}
37+
{{- else }}
38+
{{ fail "neither postgresql.enabled or backend.postgresql.existingHost are set, please pick one" }}
39+
{{- end }}
3140
- name: DATABASE_PORT
3241
value: "5432"
3342
- name: DATABASE_USER
@@ -40,7 +49,11 @@ spec:
4049
- name: SECRET_KEY
4150
valueFrom:
4251
secretKeyRef:
52+
{{- if .Values.existingSecret }}
53+
name: {{ .Values.existingSecret | quote }}
54+
{{- else }}
4355
name: "{{ template "caluma.fullname" . }}-backend"
56+
{{- end }}
4457
key: secretkey
4558
- name: ALLOWED_HOSTS
4659
value: "{{ .Values.allowedHosts }}"

charts/caluma/templates/backend-secret.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if not .Values.existingSecret }}
12
{{- $fullName := include "caluma.fullname" . -}}
23
apiVersion: v1
34
kind: Secret
@@ -9,3 +10,4 @@ metadata:
910
type: Opaque
1011
data:
1112
secretkey: {{ if .Values.secretKey }}{{ .Values.secretKey | b64enc | quote }}{{ else }}{{ randAlphaNum 40 | b64enc | quote }}{{ end }}
13+
{{- end }}

charts/caluma/values.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ nameOverride: ""
3232
fullnameOverride: ""
3333

3434
secretKey: "SUPERSECRET"
35+
# instead of exposing the secretKey in the values, a existingSecret can be defined
36+
# if set no secret will be created by the Helm chart.
37+
# create the secret manually:
38+
# kubectl create secret generic -n your-namespace --from-literal=secretKey=SUPERSECRETKEY
39+
existingSecret: ""
3540
allowedHosts: "*"
3641

3742
frontend:
@@ -54,6 +59,12 @@ backend:
5459
service:
5560
type: ClusterIP
5661

62+
postgresql:
63+
## Optionally sepcify an existing database host to connect to
64+
## this can only be used if postgresql.enabled is set to false
65+
existingHost: ""
66+
67+
5768
ingress:
5869
enabled: false
5970
annotations: {}

0 commit comments

Comments
 (0)