From cd55736f2ce4579e780b5ab28493cc3bff9ca7d4 Mon Sep 17 00:00:00 2001 From: Ari Sosnovsky Date: Sun, 4 May 2025 15:41:40 -0400 Subject: [PATCH] authelia Sun 04 May 2025 03:41:40 PM EDT --- .../templates/_helpers/start-up.sh.tpl | 17 ++++++++++ charts/apps/authelia/templates/cm.yaml | 17 +++++----- charts/apps/authelia/templates/deploy.yaml | 33 +++++++++++++++---- 3 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 charts/apps/authelia/templates/_helpers/start-up.sh.tpl diff --git a/charts/apps/authelia/templates/_helpers/start-up.sh.tpl b/charts/apps/authelia/templates/_helpers/start-up.sh.tpl new file mode 100644 index 0000000..a3f07a2 --- /dev/null +++ b/charts/apps/authelia/templates/_helpers/start-up.sh.tpl @@ -0,0 +1,17 @@ + +{{ define "authelia.scripts.startUp" }} +#!/bin/sh + +users_folder="{{ .authentication_backend.file.path }}" +initial_password=$(authelia crypto hash generate --password admin | sed 's/^Digest: //') + +if [ ! -f ${users_folder} ]; then + echo "users:" >> $users_folder + echo " admin:" >> $users_folder + echo " disabled: false" >> $users_folder + echo " password: '$initial_password'" >> $users_folder + echo " groups:" >> $users_folder + echo " - admin" >> $users_folder +fi + +{{ end }} \ No newline at end of file diff --git a/charts/apps/authelia/templates/cm.yaml b/charts/apps/authelia/templates/cm.yaml index 0f6c519..e29c4aa 100644 --- a/charts/apps/authelia/templates/cm.yaml +++ b/charts/apps/authelia/templates/cm.yaml @@ -1,11 +1,12 @@ -# --- -# apiVersion: v1 -# kind: Secret -# metadata: -# name: authelia-files -# data: -# logo.png: ".Files.Get "files/logo.png" | b64enc }}" -# favicon.ico: ".Files.Get "files/favico.svg" | b64enc }}" +{{ $config := tpl (.Values.authelia.configuration | toYaml) . }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: authelia-files +stringData: + start_up.sh: |- + {{ include "authelia.scripts.startUp" ($config | fromYaml) | nindent 4 }} --- apiVersion: v1 kind: ConfigMap diff --git a/charts/apps/authelia/templates/deploy.yaml b/charts/apps/authelia/templates/deploy.yaml index bc64d6f..6534d62 100644 --- a/charts/apps/authelia/templates/deploy.yaml +++ b/charts/apps/authelia/templates/deploy.yaml @@ -35,10 +35,31 @@ spec: configMap: name: authelia-config defaultMode: 0400 - # - name: files - # secret: - # secretName: authelia-files - # defaultMode: 0400 + - name: files + secret: + secretName: authelia-files + defaultMode: 0400 + initContainers: + - name: setup-script + image: "{{ .Values.authelia.image }}" + envFrom: + - secretRef: + name: authelia-db-secrets + - secretRef: + name: authelia-redis-secrets + - secretRef: + name: authelia-secrets + volumeMounts: + - mountPath: "/config" + name: config-data + - mountPath: /config/configuration.yml + subPath: configuration.yml + name: config-yaml + - mountPath: /config/assets/ + name: files + command: ["sh"] + args: + - "/config/assets/start_up.sh" containers: - name: authelia image: "{{ .Values.authelia.image }}" @@ -55,8 +76,8 @@ spec: - mountPath: /config/configuration.yml subPath: configuration.yml name: config-yaml - # - mountPath: /config/assets/ - # name: files + - mountPath: /config/assets/ + name: files resources: requests: memory: "1Gi"