Skip to content

Commit 08f3f2e

Browse files
authored
Merge pull request #133 from LiquidPL/main
[lldap] allow specifying app and database credentials as external secrets
2 parents a06ae70 + 36c4cf4 commit 08f3f2e

File tree

7 files changed

+136
-24
lines changed

7 files changed

+136
-24
lines changed

charts/lldap/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type: application
88
# This is the chart version. This version number should be incremented each time you make changes
99
# to the chart and its templates, including the app version.
1010
# Versions are expected to follow Semantic Versioning (https://semver.org/)
11-
version: 0.4.3
11+
version: 0.5.0
1212

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

charts/lldap/templates/_helpers.tpl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ Create the name of the service account to use
6161
{{- end }}
6262
{{- end }}
6363

64+
{{/*
65+
Create the name of the credentials secret
66+
*/}}
67+
{{- define "lldap.credentialsSecretName" -}}
68+
{{ .Values.lldap.secretName | default (printf "%s-credentials" (include "lldap.fullname" .)) }}
69+
{{- end }}
70+
6471
{{/*
6572
Build database connection strings as templates
6673
*/}}
@@ -75,4 +82,4 @@ mysql://{{- .Values.mariadb.auth.username -}}:{{- .Values.mariadb.auth.password
7582
{{- end }}
7683
{{- define "lldap.externalMariadbConnectString" -}}
7784
mysql://{{- .Values.externalMariadb.auth.username -}}:{{- .Values.externalMariadb.auth.password -}}@{{- .Values.externalMariadb.auth.host -}}:{{- .Values.externalMariadb.auth.port -}}/{{- .Values.externalMariadb.auth.database -}}
78-
{{- end }}
85+
{{- end }}

charts/lldap/templates/bootstrap-job.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
name: {{ include "lldap.fullname" . }}-bootstrap
66
# Next annotations are required if the job managed by Argo CD,
77
# so Argo CD can relaunch the job on every app sync action
8-
annotations:
8+
annotations:
99
argocd.argoproj.io/hook: PostSync
1010
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
1111
spec:
@@ -23,10 +23,10 @@ spec:
2323
- name: LLDAP_ADMIN_USERNAME
2424
value: "{{ .Values.lldap.ldapUserDN }}"
2525
- name: LLDAP_ADMIN_PASSWORD
26-
valueFrom:
27-
secretKeyRef:
28-
name: {{ include "lldap.fullname" . }}-credentials
29-
key: ldapUserPass
26+
valueFrom:
27+
secretKeyRef:
28+
name: {{ include "lldap.credentialsSecretName" . }}
29+
key: {{ .Values.lldap.ldapUserPassKey }}
3030
- name: DO_CLEANUP
3131
value: "{{ .Values.bootstrap.cleanup }}"
3232
volumeMounts:

charts/lldap/templates/deployment.yaml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,32 @@ spec:
5959
- name: LLDAP_HTTP_PORT
6060
value: "{{ .Values.service.http.port }}"
6161
- name: LLDAP_JWT_SECRET
62-
valueFrom:
63-
secretKeyRef:
64-
name: {{ include "lldap.fullname" . }}-credentials
65-
key: jwtSecret
62+
valueFrom:
63+
secretKeyRef:
64+
name: {{ include "lldap.credentialsSecretName" . }}
65+
key: {{ .Values.lldap.jwtSecretKey }}
6666
- name: LLDAP_LDAP_USER_PASS
67-
valueFrom:
68-
secretKeyRef:
69-
name: {{ include "lldap.fullname" . }}-credentials
70-
key: ldapUserPass
67+
valueFrom:
68+
secretKeyRef:
69+
name: {{ include "lldap.credentialsSecretName" . }}
70+
key: {{ .Values.lldap.ldapUserPassKey }}
7171
- name: LLDAP_DATABASE_URL
7272
{{- if .Values.postgresql.enabled }}
7373
value: {{ include "lldap.postgresConnectString" . | quote }}
74+
{{- else if and .Values.externalPostgresql.enabled .Values.externalPostgresql.fromSecret }}
75+
valueFrom:
76+
secretKeyRef:
77+
name: {{ .Values.externalPostgresql.fromSecret }}
78+
key: {{ .Values.externalPostgresql.uriKey }}
7479
{{- else if .Values.externalPostgresql.enabled }}
7580
value: {{ include "lldap.externalPostgresConnectString" . | quote }}
7681
{{- else if .Values.mariadb.enabled }}
7782
value: {{ include "lldap.mariadbConnectString" . | quote }}
83+
{{- else if and .Values.externalMariadb.enabled .Values.externalMariadb.fromSecret }}
84+
valueFrom:
85+
secretKeyRef:
86+
name: {{ .Values.externalMariadb.fromSecret }}
87+
key: {{ .Values.externalMariadb.uriKey }}
7888
{{- else if .Values.externalMariadb.enabled }}
7989
value: {{ include "lldap.externalMariadbConnectString" . | quote }}
8090
{{- else }}
@@ -87,7 +97,10 @@ spec:
8797
- name: LLDAP_VERBOSE
8898
value: "{{ .Values.lldap.verbose }}"
8999
- name: LLDAP_KEY_SEED
90-
value: "{{ .Values.lldap.keySeed }}"
100+
valueFrom:
101+
secretKeyRef:
102+
name: {{ include "lldap.credentialsSecretName" . }}
103+
key: {{ .Values.lldap.keySeedKey }}
91104
{{- if $.Values.lldap.smtp.enablePasswordReset }}
92105
- name: LLDAP_SMTP_OPTIONS__ENABLE_PASSWORD_RESET
93106
value: "{{ .Values.lldap.smtp.enablePasswordReset }}"
@@ -104,10 +117,10 @@ spec:
104117
- name: LLDAP_SMTP_OPTIONS__REPLY_TO
105118
value: "{{ .Values.lldap.smtp.replyTo }}"
106119
- name: LLDAP_SMTP_OPTIONS__PASSWORD
107-
valueFrom:
108-
secretKeyRef:
109-
name: {{ include "lldap.fullname" . }}-credentials
110-
key: smtpPassword
120+
valueFrom:
121+
secretKeyRef:
122+
name: {{ include "lldap.credentialsSecretName" . }}
123+
key: {{ .Values.lldap.smtp.passwordKey }}
111124
{{- end }}
112125
{{- if $.Values.lldap.ldaps.enabled }}
113126
- name: LLDAP_LDAPS_OPTIONS__ENABLED

charts/lldap/templates/secret.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
{{ if not .Values.lldap.secretName }}
12
kind: Secret
23
apiVersion: v1
34
type: Opaque
45
metadata:
56
name: {{ include "lldap.fullname" . }}-credentials
67
data:
7-
jwtSecret: {{ .Values.lldap.jwtSecret | b64enc }}
8-
ldapUserPass: {{ .Values.lldap.ldapUserPass | b64enc }}
9-
smtpPassword: {{ .Values.lldap.smtp.password | b64enc }}
8+
{{ .Values.lldap.jwtSecretKey }}: {{ .Values.lldap.jwtSecret | b64enc }}
9+
{{ .Values.lldap.ldapUserPassKey }}: {{ .Values.lldap.ldapUserPass | b64enc }}
10+
{{ .Values.lldap.smtp.passwordKey }}: {{ .Values.lldap.smtp.password | b64enc }}
11+
{{ .Values.lldap.keySeedKey }}: {{ .Values.lldap.keySeedKey | b64enc }}
12+
{{ end }}

charts/lldap/values.schema.json

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,20 @@
188188
"required": [],
189189
"title": "enabled",
190190
"type": "boolean"
191+
},
192+
"fromSecret": {
193+
"default": null,
194+
"description": "Name of the secret containing the database URI",
195+
"required": [],
196+
"title": "fromSecret",
197+
"type": "string"
198+
},
199+
"uriKey": {
200+
"default": null,
201+
"description": "Name of the secret key containing the database URI",
202+
"required": [],
203+
"title": "uriKey",
204+
"type": "string"
191205
}
192206
},
193207
"required": [],
@@ -239,6 +253,20 @@
239253
"required": [],
240254
"title": "enabled",
241255
"type": "boolean"
256+
},
257+
"fromSecret": {
258+
"default": null,
259+
"description": "Name of the secret containing the database URI",
260+
"required": [],
261+
"title": "fromSecret",
262+
"type": "string"
263+
},
264+
"uriKey": {
265+
"default": null,
266+
"description": "Name of the secret key containing the database URI",
267+
"required": [],
268+
"title": "uriKey",
269+
"type": "string"
242270
}
243271
},
244272
"required": [],
@@ -435,20 +463,41 @@
435463
"title": "gid",
436464
"type": "integer"
437465
},
466+
"secretName": {
467+
"default": null,
468+
"description": "Name of Kubernetes secret containing credentials",
469+
"required": [],
470+
"title": "secretName",
471+
"type": "string"
472+
},
438473
"jwtSecret": {
439474
"default": "REPLACE_WITH_RANDOM",
440475
"description": "Random secret for JWT signature.\nThis secret should be random, and should be shared with application servers that need to\nconsume the JWTs. Changing this secret will invalidate all user sessions and require them\nto re-login. You can generate it with (on linux):\nLC_ALL=C tr -dc 'A-Za-z0-9!#%\u0026'\\''()*+,-./:;\u003c=\u003e?@[\\]^_{|}~' \u003c/dev/urandom | head -c 32; echo ''",
441476
"required": [],
442477
"title": "jwtSecret",
443478
"type": "string"
444479
},
480+
"jwtSecretKey": {
481+
"default": "jwtSecret",
482+
"description": "Name of the JWT signature key in the credentials secret",
483+
"required": [],
484+
"title": "jwtSecretKey",
485+
"type": "string"
486+
},
445487
"keySeed": {
446488
"default": "REPLACE_WITH_RANDOM",
447489
"description": "Seed to generate the server private key. This can be any random string, the recommendation\nis that it's at least 12 characters long.",
448490
"required": [],
449491
"title": "keySeed",
450492
"type": "string"
451493
},
494+
"keySeedKey": {
495+
"default": "keySeed",
496+
"description": "Name of the key containing the private key seed in the credentials secret",
497+
"required": [],
498+
"title": "keySeedKey",
499+
"type": "string"
500+
},
452501
"ldapUserDN": {
453502
"default": "admin",
454503
"description": "Admin username.\nFor the LDAP interface, a value of \"admin\" here will create the LDAP user\n\"cn=admin,ou=people,dc=example,dc=com\" (with the base DN above). For the administration\ninterface, this is the username.",
@@ -463,6 +512,13 @@
463512
"title": "ldapUserPass",
464513
"type": "string"
465514
},
515+
"ldapUserPassKey": {
516+
"default": "ldapUserPass",
517+
"description": "Name of the LDAP admin password key in the credentials secret",
518+
"required": [],
519+
"title": "ldapUserPassKey",
520+
"type": "string"
521+
},
466522
"ldaps": {
467523
"description": "Options to configure LDAPS",
468524
"properties": {
@@ -516,6 +572,13 @@
516572
"title": "password",
517573
"type": "string"
518574
},
575+
"passwordKey": {
576+
"default": "password",
577+
"description": "Name of the SMTP password in the credentials secret",
578+
"required": [],
579+
"title": "passwordKey",
580+
"type": "string"
581+
},
519582
"port": {
520583
"default": 587,
521584
"description": "The SMTP port.",
@@ -944,4 +1007,4 @@
9441007
},
9451008
"required": [],
9461009
"type": "object"
947-
}
1010+
}

charts/lldap/values.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,22 @@ lldap:
2525
# actually need to own the domain name.
2626
baseDN: "dc=example,dc=com"
2727

28+
# -- Name of the Kubernetes secret containing credentials.
29+
# If this isn't specified, a secret will be generated with the credentials provided
30+
# in the values file. If you want to provide an external secret, for instance when
31+
# deploying with GitOps, specify its name here.
32+
secretName: ~
33+
2834
# -- Random secret for JWT signature.
2935
# This secret should be random, and should be shared with application servers that need to
3036
# consume the JWTs. Changing this secret will invalidate all user sessions and require them
3137
# to re-login. You can generate it with (on linux):
3238
# LC_ALL=C tr -dc 'A-Za-z0-9!#%&'\''()*+,-./:;<=>?@[\]^_{|}~' </dev/urandom | head -c 32; echo ''
3339
jwtSecret: REPLACE_WITH_RANDOM
3440

41+
# -- Name of the JWT signature key in the `.Values.lldap.secretName` Kubernetes secret.
42+
jwtSecretKey: jwtSecret
43+
3544
# -- Admin username.
3645
# For the LDAP interface, a value of "admin" here will create the LDAP user
3746
# "cn=admin,ou=people,dc=example,dc=com" (with the base DN above). For the administration
@@ -44,10 +53,16 @@ lldap:
4453
# Note: you can create another admin user for user administration, this is just the default one.
4554
ldapUserPass: REPLACE_WITH_RANDOM
4655

56+
# -- Name of the LDAP admin password key in the `.Values.lldap.secretName` Kubernetes secret.
57+
ldapUserPassKey: ldapUserPass
58+
4759
# -- Seed to generate the server private key. This can be any random string, the recommendation
4860
# is that it's at least 12 characters long.
4961
keySeed: REPLACE_WITH_RANDOM
5062

63+
# -- Name of the key holding the private key seed in the `.Values.lldap.secretName` Kubernetes secret.
64+
keySeedKey: keySeed
65+
5166
uid: 1000
5267
gid: 1000
5368
tz: "Etc/UTC"
@@ -70,6 +85,9 @@ lldap:
7085
user: "sender@gmail.com"
7186
# -- The SMTP password.
7287
password: "password"
88+
# -- Name of the SMTP password key in the `.Values.lldap.secretName` Kubernetes secret.
89+
# Overrides the `.Values.lldap.smtp.password` if a custom secret is defined.
90+
passwordKey: smtpPassword
7391
# -- The header field: how the sender appears in the email. The first
7492
# is a free-form name, followed by an email between <>. Optional.
7593
from: "LLDAP Admin <sender@gmail.com>"
@@ -214,6 +232,10 @@ postgresql:
214232
# --- Enable and configure external postgresql database
215233
externalPostgresql:
216234
enabled: false
235+
# -- Name of the Kubernetes secret containing the database URI
236+
# fromSecret:
237+
# -- Name of the secret key containing the database URI
238+
# uriKey:
217239
auth:
218240
host: ""
219241
port: 5432
@@ -244,6 +266,10 @@ mariadb:
244266
# -- Enable and configure external mariadb database
245267
externalMariadb:
246268
enabled: false
269+
# -- Name of the Kubernetes secret containing the database URI
270+
# fromSecret:
271+
# -- Name of the secret key containing the database URI
272+
# uriKey:
247273
auth:
248274
host: ""
249275
port: 3306

0 commit comments

Comments
 (0)