Skip to content

Commit 8bbf403

Browse files
committed
Randomize pass if value is empty. Override if secret is specified
Signed-off-by: Scott Rigby <[email protected]>
1 parent ba818ba commit 8bbf403

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

chart/templates/_helpers.tpl

+13
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ Expand the name of the chart.
1919
{{- end }}
2020
{{- end }}
2121

22+
{{/*
23+
Get the admin password value or a randomly generated password.
24+
Note adminPassword is deprecated, and will be removed in a future version.
25+
*/}}
26+
{{- define "mission-control.admin.password" -}}
27+
{{- if .Values.admin.password -}}
28+
{{ .Values.admin.password -}}
29+
{{- else if .Values.adminPassword -}}
30+
{{ .Values.adminPassword -}}
31+
{{- else -}}
32+
{{ randAlphaNum 10 }}
33+
{{- end -}}
34+
{{- end -}}
2235

2336
{{/*
2437
Create chart name and version as used by the chart label.

chart/templates/deployment.yaml

+9-1
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,16 @@ spec:
4444
secretKeyRef:
4545
name: {{ .Values.db.jwtSecretKeyRef.name }}
4646
key: {{ .Values.db.jwtSecretKeyRef.key }}
47+
{{- if ne .Values.admin.existingSecret "" }}
4748
- name: ADMIN_PASSWORD
48-
value: {{ .Values.adminPassword }}
49+
valueFrom:
50+
secretKeyRef:
51+
name: {{ .Values.admin.existingSecret }}
52+
key: admin-password
53+
{{- else }}
54+
- name: ADMIN_PASSWORD
55+
value: {{ include "mission-control.admin.password" . }}
56+
{{- end }}
4957
envFrom:
5058
- secretRef:
5159
name: {{ .Values.smtp.secretRef.name }}

chart/values.yaml

+12-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,18 @@ smtp:
106106
# SMTP_PORT: <port>
107107
# SMTP_USER: <user>
108108
# SMTP_PASSWORD: <password>
109-
adminPassword: admin
109+
# DEPRECATED - adminPassword is deprecated, and will be removed in a future version.
110+
# adminPassword: ""
111+
admin:
112+
# If you leave this empty, and do not override with admin.existingSecret, a
113+
# random password will be generated for you.
114+
password: ""
115+
# Specifying an existing secret name will override the admin.password.
116+
# The secret key must be "admin-password"
117+
# For example, to create from a file:
118+
# echo -n 'S!B\*d$zDsb=' > ./admin-password.txt
119+
# kubectl create secret generic admin-password-secret --from-file=admin-password.txt
120+
existingSecret: ""
110121
canary-checker:
111122
image:
112123
type: full

0 commit comments

Comments
 (0)