feat(recipes): move SECRET_KEY to autogenerated remembered secret (#1559)

* feat(recipes): move `SECRET_KEY` to autogenerated remembered secret

* bump major
This commit is contained in:
Stavros Kois
2021-12-19 00:45:49 +02:00
committed by GitHub
parent a11e96d75e
commit 27046d1841
5 changed files with 29 additions and 15 deletions

View File

@@ -2,7 +2,7 @@ apiVersion: v2
appVersion: "1.0.2"
description: Recipes is a Django application to manage, tag and search recipes using either built in models or external storage providers hosting PDF's, Images or other files.
name: recipes
version: 4.0.18
version: 5.0.0
kubeVersion: ">=1.16.0-0"
keywords:
- recipes

View File

@@ -73,18 +73,6 @@ questions:
- value: "OnDelete"
description: "(Legacy) OnDelete: ignore .spec.template changes"
# Include{controllerExpert}
- variable: secret
group: "Container Configuration"
label: "Image Secrets"
schema:
type: dict
attrs:
- variable: SECRET_KEY
label: "SECRET_KEY"
description: "Sets the SECRET_KEY env var"
schema:
type: string
default: "changeme"
- variable: env
group: "Container Configuration"
label: "Image Environment"

View File

@@ -0,0 +1,20 @@
{{/* Define the secrets */}}
{{- define "recipes.secrets" -}}
---
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: recipes-secrets
{{- $recipesprevious := lookup "v1" "Secret" .Release.Namespace "recipes-secrets" }}
{{- $secret_key := "" }}
data:
{{- if $recipesprevious}}
SECRET_KEY: {{ index $recipesprevious.data "SECRET_KEY" }}
{{- else }}
{{- $secret_key := randAlphaNum 50 }}
SECRET_KEY: {{ $secret_key | b64enc | quote }}
{{- end }}
{{- end -}}

View File

@@ -14,5 +14,8 @@ persistence:
{{- end -}}
{{- $_ := mergeOverwrite .Values (include "recipes.harcodedValues" . | fromYaml) -}}
{{/* Render secrets for recipes */}}
{{- include "recipes.secrets" . }}
{{/* Render the templates */}}
{{ include "common.postSetup" . }}

View File

@@ -23,16 +23,15 @@ podSecurityContext:
# -- environment variables. See [project docs](https://raw.githubusercontent.com/vabene1111/recipes/master/.env.template) for more details.
# @default -- See below
env:
TIMEZONE: UTC
DEBUG: 0
ALLOWED_HOSTS: "*"
SECRET_KEY: "changeme"
GUNICORN_MEDIA: 0
FRACTION_PREF_DEFAULT: 0
COMMENT_PREF_DEFAULT: 1
SHOPPING_MIN_AUTOSYNC_INTERVAL: 5
envTpl:
TIMEZONE: "{{ .Values.env.TZ }}"
DB_ENGINE: "django.db.backends.postgresql"
POSTGRES_DB: "{{ .Values.postgresql.postgresqlDatabase }}"
POSTGRES_USER: "{{ .Values.postgresql.postgresqlUsername }}"
@@ -47,6 +46,10 @@ envValueFrom:
secretKeyRef:
name: dbcreds
key: plainhost
SECRET_KEY:
secretKeyRef:
name: recipes-secrets
key: SECRET_KEY
additionalContainers:
nginx: