Refactor environment variables in deployment template

The environment variables for the Paperless-NGX deployment have been
refactored and moved into the main container section within the
Kubernetes deployment manifest. This change organizes the
environment variable definitions, enhancing readability and
maintainability.

Key modifications include:
- Moved the `env` section under `containers.main`, allowing for
  a clearer structure.
- Retained the logic for PostgreSQL, MariaDB, and Redis database
  configuration while ensuring environment variables are set
  within the context of the main application container.

This change does not introduce any breaking functionality, but
it does improve the clarity and intent of the configuration.
This commit is contained in:
2025-11-23 13:01:43 +01:00
parent 5bac34870f
commit d3a54f13b0
2 changed files with 52 additions and 48 deletions

View File

@@ -1,48 +1,53 @@
{{/* Append the hardcoded settings */}} {{/* Append the hardcoded settings */}}
{{- define "healthchecks.harcodedValues" -}} {{- define "healthchecks.harcodedValues" -}}
env: controllers:
PAPERLESS_TIME_ZONE: {{ .Values.env.TZ }} main:
PAPERLESS_PORT: {{ quote .Values.service.main.ports.http.port }} type: deployment
containers:
main:
env:
PAPERLESS_TIME_ZONE: {{ .Values.env.TZ }}
PAPERLESS_PORT: {{ quote .Values.service.main.ports.http.port }}
{{- with .Values.ingress.main }} {{- with .Values.ingress.main }}
{{- if and .enabled .hosts }} {{- if and .enabled .hosts }}
PAPERLESS_URL: http{{ if .tls }}s{{ end }}://{{ (first .hosts).host }} PAPERLESS_URL: http{{ if .tls }}s{{ end }}://{{ (first .hosts).host }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- if .Values.postgresql.enabled }} {{- if .Values.postgresql.enabled }}
{{- with .Values.postgresql }} {{- with .Values.postgresql }}
PAPERLESS_DBENGINE: postgresql PAPERLESS_DBENGINE: postgresql
PAPERLESS_DBHOST: {{ $.Release.Name }}-postgresql PAPERLESS_DBHOST: {{ $.Release.Name }}-postgresql
PAPERLESS_DBNAME: {{ .auth.database }} PAPERLESS_DBNAME: {{ .auth.database }}
PAPERLESS_DBUSER: {{ default "postgres" .auth.username }} PAPERLESS_DBUSER: {{ default "postgres" .auth.username }}
PAPERLESS_DBPASS: PAPERLESS_DBPASS:
secretKeyRef: secretKeyRef:
name: {{ .auth.existingSecret | default (printf "%s-postgresql" $.Release.Name) }} name: {{ .auth.existingSecret | default (printf "%s-postgresql" $.Release.Name) }}
key: {{ if not .auth.password }}postgres-{{ end }}password key: {{ if not .auth.password }}postgres-{{ end }}password
{{- end }} {{- end }}
{{- else if .Values.mariadb.enabled }} {{- else if .Values.mariadb.enabled }}
{{- with .Values.mariadb}} {{- with .Values.mariadb}}
PAPERLESS_DBENGINE: mariadb PAPERLESS_DBENGINE: mariadb
PAPERLESS_DBHOST: {{ $.Release.Name }}-mariadb PAPERLESS_DBHOST: {{ $.Release.Name }}-mariadb
PAPERLESS_DBNAME: {{ .auth.database }} PAPERLESS_DBNAME: {{ .auth.database }}
PAPERLESS_DBUSER: {{ .auth.username }} PAPERLESS_DBUSER: {{ .auth.username }}
PAPERLESS_DBPASS: PAPERLESS_DBPASS:
secretKeyRef: secretKeyRef:
name: {{ .auth.existingSecret | default (printf "%s-mariadb" $.Release.Name) }} name: {{ .auth.existingSecret | default (printf "%s-mariadb" $.Release.Name) }}
key: mariadb-password key: mariadb-password
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- if .Values.redis.enabled }} {{- if .Values.redis.enabled }}
{{- with .Values.redis }} {{- with .Values.redis }}
A_REDIS_PASSWORD: A_REDIS_PASSWORD:
secretKeyRef: secretKeyRef:
name: {{ .auth.existingSecret | default (printf "%s-redis" $.Release.Name) }} name: {{ .auth.existingSecret | default (printf "%s-redis" $.Release.Name) }}
key: {{ .auth.existingSecretPasswordKey | default "redis-password" }} key: {{ .auth.existingSecretPasswordKey | default "redis-password" }}
PAPERLESS_REDIS: redis://{{ .auth.username }}:$(A_REDIS_PASSWORD)@{{ $.Release.Name }}-redis-master PAPERLESS_REDIS: redis://{{ .auth.username }}:$(A_REDIS_PASSWORD)@{{ $.Release.Name }}-redis-master
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end -}} {{- end -}}
{{- $_ := merge .Values (include "healthchecks.harcodedValues" . | fromYaml) -}} {{- $_ := merge .Values (include "healthchecks.harcodedValues" . | fromYaml) -}}

View File

@@ -20,11 +20,10 @@ controllers:
# @default -- See [values.yaml](./values.yaml) # @default -- See [values.yaml](./values.yaml)
# -- Set the resource requests / limits for the container. # -- Set the resource requests / limits for the container.
resources: {} resources: {}
env:
env: # -- Set the container timezone
# -- Set the container timezone TZ: UTC
TZ: UTC # PAPERLESS_SECRET_KEY: ""
# PAPERLESS_SECRET_KEY: ""
service: service:
# -- Configures service settings for the chart. # -- Configures service settings for the chart.