Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomize pass if value is empty. Override if secret is specified #141

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ Expand the name of the chart.
{{- end }}
{{- end }}

{{/*
Get the admin password value or a randomly generated password.
Note adminPassword is deprecated, and will be removed in a future version.
*/}}
{{- define "mission-control.admin.password" -}}
{{- if .Values.admin.password -}}
{{ .Values.admin.password -}}
{{- else if .Values.adminPassword -}}
{{ .Values.adminPassword -}}
{{- else -}}
{{ randAlphaNum 10 }}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
Expand Down
10 changes: 9 additions & 1 deletion chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,16 @@ spec:
secretKeyRef:
name: {{ .Values.db.jwtSecretKeyRef.name }}
key: {{ .Values.db.jwtSecretKeyRef.key }}
{{- if ne .Values.admin.existingSecret "" }}
- name: ADMIN_PASSWORD
value: {{ .Values.adminPassword }}
valueFrom:
secretKeyRef:
name: {{ .Values.admin.existingSecret }}
key: admin-password
{{- else }}
- name: ADMIN_PASSWORD
value: {{ include "mission-control.admin.password" . }}
{{- end }}
envFrom:
- secretRef:
name: {{ .Values.smtp.secretRef.name }}
Expand Down
13 changes: 12 additions & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,18 @@ smtp:
# SMTP_PORT: <port>
# SMTP_USER: <user>
# SMTP_PASSWORD: <password>
adminPassword: admin
# DEPRECATED - adminPassword is deprecated, and will be removed in a future version.
# adminPassword: ""
admin:
# If you leave this empty, and do not override with admin.existingSecret, a
# random password will be generated for you.
password: ""
# Specifying an existing secret name will override the admin.password.
# The secret key must be "admin-password"
# For example, to create from a file:
# echo -n 'S!B\*d$zDsb=' > ./admin-password.txt
# kubectl create secret generic admin-password-secret --from-file=admin-password.txt
existingSecret: ""
Comment on lines +111 to +120
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can skip passing in a plaintext password, if you want to specify a password then you must create the secret before and set create: false

Suggested change
admin:
# If you leave this empty, and do not override with admin.existingSecret, a
# random password will be generated for you.
password: ""
# Specifying an existing secret name will override the admin.password.
# The secret key must be "admin-password"
# For example, to create from a file:
# echo -n 'S!B\*d$zDsb=' > ./admin-password.txt
# kubectl create secret generic admin-password-secret --from-file=admin-password.txt
existingSecret: ""
adminPassword:
secretKeyRef:
create: true # set to false if you want to pass in an existing secret
name: mission-control-admin-password
key: password

canary-checker:
image:
type: full
Expand Down