Skip to content

Commit 4bdebce

Browse files
committed
introduce the concept of configVariables
they are environment variables that can be sourced from raw values or any other env source and can also be templated to refer to values from helm. they can be defined globally or per service, while per service definitions overwrite globals.
1 parent 814e685 commit 4bdebce

File tree

5 files changed

+57
-18
lines changed

5 files changed

+57
-18
lines changed

charts/docspell/Chart.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ name: docspell
33
description: A Helm chart to deploy docspell to Kubernetes
44
home: https://docspell.org/
55
type: application
6-
version: 0.0.19
6+
version: 0.0.20
77
# this only tracks the restserver, but restserver's and joex's versions are synced
88
# renovate: image=ghcr.io/docspell/restserver
99
appVersion: "0.43.0"
10-

charts/docspell/templates/_helpers.tpl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,28 @@ Selector labels
4949
app.kubernetes.io/name: {{ include "docspell.name" . }}
5050
app.kubernetes.io/instance: {{ .Release.Name }}
5151
{{- end }}
52+
53+
{{- define "docspell.configVariables" -}}
54+
{{- $configVars := dict }}
55+
{{- range $source := .Sources -}}
56+
{{- $configVars = mergeOverwrite $configVars (deepCopy $source) -}}
57+
{{- end }}
58+
{{- range $name, $config := $configVars }}
59+
{{- if $config.value }}
60+
- name: {{ $name }}
61+
{{- if $config.template }}
62+
value: {{ tpl $config.value $.Root | quote }}
63+
{{- else }}
64+
value: {{ $config.value | quote }}
65+
{{- end }}
66+
{{- else if $config.valueFrom }}
67+
- name: {{ $name }}
68+
{{- if $config.template }}
69+
valueFrom: {{- tpl ($config.valueFrom | toYaml) $.Root | nindent 4 }}
70+
{{- else }}
71+
valueFrom: {{- $config.valueFrom | nindent 4 }}
72+
{{- end }}
73+
{{- else }}
74+
{{- end }}
75+
{{- end }}
76+
{{- end }}

charts/docspell/templates/statefulset-joex.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ spec:
3636
{{- end }}
3737
- '--'
3838
- '/opt/docspell.conf'
39-
envFrom:
40-
- secretRef:
41-
name: {{ .Values.jdbc.credentialsSecretName }}
39+
env:
40+
{{- include "docspell.configVariables" (dict "Sources" (list .Values.configVariables .Values.joex.configVariables) "Root" $) | nindent 8 }}
4241
ports:
4342
- name: api
4443
containerPort: 7878

charts/docspell/templates/statefulset-restserver.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ spec:
2828
image: {{ print .Values.restserver.image.repo ":" (.Values.restserver.image.tag | default .Values.image.tag | default (print "v" .Chart.AppVersion)) | quote }}
2929
imagePullPolicy: {{ .Values.restserver.image.pullPolicy | default .Values.image.pullPolicy | quote }}
3030
args: ['/opt/docspell.conf']
31-
envFrom:
32-
- secretRef:
33-
name: {{ .Values.jdbc.credentialsSecretName }}
31+
env:
32+
{{- include "docspell.configVariables" (dict "Sources" (list .Values.configVariables .Values.restserver.configVariables) "Root" $) | nindent 8 }}
3433
volumeMounts:
3534
- name: config
3635
mountPath: /opt/docspell.conf

charts/docspell/values.yaml

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ jdbc:
1111
port: 5432
1212
database: docspell
1313
credentialsSecretName: credentialsSecretName
14+
config: |
15+
jdbc {
16+
url = ${JDBC_URI}
17+
user = ${JDBC_USERNAME}
18+
password = ${JDBC_PASSWORD}
19+
}
1420
1521
files:
1622
config: ''
@@ -23,11 +29,29 @@ fullTextSearchConfig: |
2329
use-default-connection = true
2430
}
2531
32+
configVariables:
33+
JDBC_URI:
34+
template: true
35+
value: 'jdbc:postgresql://{{ .Values.jdbc.host }}:{{ .Values.jdbc.port }}/{{ .Values.jdbc.database }}'
36+
JDBC_USERNAME:
37+
template: true
38+
valueFrom:
39+
secretKeyRef:
40+
name: '{{ .Values.jdbc.credentialsSecretName }}'
41+
key: username
42+
JDBC_PASSWORD:
43+
template: true
44+
valueFrom:
45+
secretKeyRef:
46+
name: '{{ .Values.jdbc.credentialsSecretName }}'
47+
key: password
48+
2649
restserver:
2750
image:
2851
repo: 'ghcr.io/docspell/restserver'
2952
tag: null
3053
pullPolicy: null
54+
configVariables: {}
3155
replicas: 1
3256
resources: {}
3357
# We usually recommend not to specify default resources and to leave this as a conscious
@@ -90,11 +114,7 @@ restserver:
90114
91115
# Configuration for the backend.
92116
backend {
93-
jdbc {
94-
url = {{ print "jdbc:postgresql://" .Values.jdbc.host ":" .Values.jdbc.port "/" .Values.jdbc.database | quote }}
95-
user = ${username}
96-
password = ${password}
97-
}
117+
{{- tpl (.Values.jdbc.config | default "" | nindent 4) $ }}
98118
99119
# Configuration for registering new users.
100120
signup {
@@ -121,6 +141,7 @@ joex:
121141
repo: 'ghcr.io/docspell/joex'
122142
tag: null
123143
pullPolicy: null
144+
configVariables: {}
124145
replicas: 1
125146
resources: {}
126147
# We usually recommend not to specify default resources and to leave this as a conscious
@@ -143,11 +164,7 @@ joex:
143164
port = 7878
144165
}
145166
146-
jdbc {
147-
url = {{ print "jdbc:postgresql://" .Values.jdbc.host ":" .Values.jdbc.port "/" .Values.jdbc.database | quote }}
148-
user = ${username}
149-
password = ${password}
150-
}
167+
{{- tpl (.Values.jdbc.config | default "" | nindent 2) $ }}
151168
152169
full-text-search {
153170
{{- .Values.fullTextSearchConfig | nindent 4 }}

0 commit comments

Comments
 (0)