Automatically generate random secrets for the redis password and django secret

This commit is contained in:
Florian Piesche 2021-03-21 12:26:31 +00:00
parent 215217bd8c
commit 094a76b647
No known key found for this signature in database
GPG key ID: CF7283FB896221F3
3 changed files with 17 additions and 6 deletions

View file

@ -7,11 +7,11 @@ Expand the name of the chart.
{{- end -}}
{{- define "funkwhale.dbUrl" -}}
postgres://{{ .Values.database.user}}:{{ .Values.database.password }}@{{ .Values.database.host }}:{{ .Values.database.port }}/{{ .Values.database.database }}
postgres://{{ .Values.database.user }}:{{ .Values.database.password }}@{{ .Values.database.host }}:{{ .Values.database.port }}/{{ .Values.database.database }}
{{- end -}}
{{- define "funkwhale.redisUrl" -}}
redis://:{{ .Values.redis.password }}@{{ .Values.redis.host | default (printf "%s-%s" (include "funkwhale.fullname" .) "redis-master") }}:{{ .Values.redis.redisPort }}/0
redis://:{{ default uuidv4 .Values.redis.password }}@{{ .Values.redis.host | default (printf "%s-%s" (include "funkwhale.fullname" .) "redis-master") }}:{{ .Values.redis.redisPort }}/0
{{- end -}}
{{/*

View file

@ -1,3 +1,5 @@
{{- $secret := (lookup "v1" "Secret" .Release.Namespace (include "funkwhale.fullname" .)) -}}
apiVersion: v1
kind: Secret
metadata:
@ -10,7 +12,11 @@ metadata:
data:
CACHE_URL: {{ include "funkwhale.redisUrl" . | b64enc }}
DATABASE_URL: {{ include "funkwhale.dbUrl" . | b64enc }}
DJANGO_SECRET_KEY: {{ .Values.djangoSecret | b64enc }}
{{ if $secret -}}
DJANGO_SECRET_KEY: {{ $secret.data.DJANGO_SECRET_KEY }}
{{ else -}}
DJANGO_SECRET_KEY: {{ (default uuidv4 .Values.djangoSecret) | b64enc }}
{{ end }}
{{- range $key, $val := .Values.extraSecret }}
{{ $key }}: {{ $val | b64enc }}

View file

@ -47,6 +47,14 @@ database:
database: funkwhale
redis:
# If you already have a Redis service you'd like to use, set
# this to false and adjust the host to use your existing service.
enabled: true
host: ''
redisPort: 6379
password: ''
cluster:
enabled: false
master:
@ -55,9 +63,6 @@ redis:
slave:
persistence:
enabled: false
password: funkwhale
redisPort: 6379
# host: {{ template "funkwhale.fullname" . }}-redis-master
djangoSecret: ''