Skip to content

Commit

Permalink
add postgresql.existingHost & existingSecret for backend's SECRETKEY (#…
Browse files Browse the repository at this point in the history
…18)

* feat(postgresql/existingSecret): add an existingSecret for the SECRETKEY and allow setting an existingHost for the database

Signed-off-by: Toni Tauro <[email protected]>

* fix(values): lint

Signed-off-by: Toni Tauro <[email protected]>

---------

Signed-off-by: Toni Tauro <[email protected]>
  • Loading branch information
eyenx authored Sep 15, 2023
1 parent 451c9b4 commit 9e9b73d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/caluma/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.10.8
version: 0.11.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
13 changes: 13 additions & 0 deletions charts/caluma/templates/backend-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ spec:
imagePullPolicy: {{ .Values.image.backend.pullPolicy }}
env:
- name: DATABASE_HOST
{{- if and .Values.postgresql.enabled .Values.backend.postgresql.existingHost }}
{{ fail "postgresql.enabled and backend.postgresql.existingHost are mutually exclusive, please pick one" }}
{{- end }}
{{- if .Values.postgresql.enabled }}
value: "{{ template "caluma.fullname" . }}-postgresql"
{{- else if .Values.backend.postgresql.existingHost }}
value: {{ .Values.backend.postgresql.existingHost | quote }}
{{- else }}
{{ fail "neither postgresql.enabled or backend.postgresql.existingHost are set, please pick one" }}
{{- end }}
- name: DATABASE_PORT
value: "5432"
- name: DATABASE_USER
Expand All @@ -40,7 +49,11 @@ spec:
- name: SECRET_KEY
valueFrom:
secretKeyRef:
{{- if .Values.existingSecret }}
name: {{ .Values.existingSecret | quote }}
{{- else }}
name: "{{ template "caluma.fullname" . }}-backend"
{{- end }}
key: secretkey
- name: ALLOWED_HOSTS
value: "{{ .Values.allowedHosts }}"
Expand Down
2 changes: 2 additions & 0 deletions charts/caluma/templates/backend-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.existingSecret }}
{{- $fullName := include "caluma.fullname" . -}}
apiVersion: v1
kind: Secret
Expand All @@ -9,3 +10,4 @@ metadata:
type: Opaque
data:
secretkey: {{ if .Values.secretKey }}{{ .Values.secretKey | b64enc | quote }}{{ else }}{{ randAlphaNum 40 | b64enc | quote }}{{ end }}
{{- end }}
11 changes: 11 additions & 0 deletions charts/caluma/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ nameOverride: ""
fullnameOverride: ""

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

frontend:
Expand All @@ -54,6 +59,12 @@ backend:
service:
type: ClusterIP

postgresql:
## Optionally sepcify an existing database host to connect to
## this can only be used if postgresql.enabled is set to false
existingHost: ""


ingress:
enabled: false
annotations: {}
Expand Down

0 comments on commit 9e9b73d

Please sign in to comment.