From bcb50a5fcedcdde9eb806c829c507c039b74ce87 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 12 Mar 2026 09:52:29 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7(helm)=20allow=20specific=20env=20v?= =?UTF-8?q?ar=20for=20the=20backend=20and=20celery=20deploy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We want the possibility to configure specific environment variables on backend and celery deployment. Most of them are common but in the case of the newly added settings DB_PSYCOPG_POOL_MIN_SIZE we want to configure ot only on the backend deployment, not on the celery or with a different value. --- CHANGELOG.md | 1 + src/helm/env.d/dev/values.impress.yaml.gotmpl | 6 ++++++ src/helm/impress/templates/_helpers.tpl | 20 +++++++++++++++++++ .../impress/templates/backend_deployment.yaml | 7 ++++--- .../templates/celery_worker_deployment.yaml | 7 ++++--- src/helm/impress/values.yaml | 14 ++++++++++++- 6 files changed, 48 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dd81e47..bd629256 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ and this project adheres to - 🐛(backend) manage race condition when creating sandbox document #1971 - 🐛(frontend) fix flickering left panel #1989 - ♿️(frontend) improve doc tree keyboard navigation #1981 +- 🔧(helm) allow specific env var for the backend and celery deploy ## [v4.7.0] - 2026-03-09 diff --git a/src/helm/env.d/dev/values.impress.yaml.gotmpl b/src/helm/env.d/dev/values.impress.yaml.gotmpl index 1144f910..1c222b1c 100644 --- a/src/helm/env.d/dev/values.impress.yaml.gotmpl +++ b/src/helm/env.d/dev/values.impress.yaml.gotmpl @@ -74,6 +74,12 @@ backend: Y_PROVIDER_API_BASE_URL: http://impress-docs-y-provider:443/api/ Y_PROVIDER_API_KEY: my-secret CACHES_KEY_PREFIX: "{{ now | unixEpoch }}" + django: + envVars: + WEB_CONCURRENCY: 1 + DB_PSYCOPG_POOL_MIN_SIZE: 10 + + migrate: command: - "/bin/sh" diff --git a/src/helm/impress/templates/_helpers.tpl b/src/helm/impress/templates/_helpers.tpl index 48140513..29530f90 100644 --- a/src/helm/impress/templates/_helpers.tpl +++ b/src/helm/impress/templates/_helpers.tpl @@ -90,6 +90,26 @@ impress env vars {{- include "impress.env.transformDict" $workerScope.envVars -}} {{- end }} +{{/* +impress backend django env vars - combines common backend.envVars with backend.django.envVars +*/}} +{{- define "impress.backend.django.env" -}} +{{- $topLevelScope := index . 0 -}} +{{- $workerScope := index . 1 -}} +{{- include "impress.env.transformDict" $workerScope.envVars -}} +{{- include "impress.env.transformDict" (($workerScope.django | default dict).envVars | default dict) -}} +{{- end }} + +{{/* +impress celery env vars - combines common backend.envVars with backend.celery.envVars +*/}} +{{- define "impress.backend.celery.env" -}} +{{- $topLevelScope := index . 0 -}} +{{- $workerScope := index . 1 -}} +{{- include "impress.env.transformDict" $workerScope.envVars -}} +{{- include "impress.env.transformDict" ($workerScope.celery.envVars | default dict) -}} +{{- end }} + {{/* Common labels diff --git a/src/helm/impress/templates/backend_deployment.yaml b/src/helm/impress/templates/backend_deployment.yaml index b43e9aa8..ec5961cc 100644 --- a/src/helm/impress/templates/backend_deployment.yaml +++ b/src/helm/impress/templates/backend_deployment.yaml @@ -1,4 +1,4 @@ -{{- $envVars := include "impress.common.env" (list . .Values.backend) -}} +{{- $envVars := include "impress.backend.django.env" (list . .Values.backend) -}} {{- $fullName := include "impress.backend.fullname" . -}} {{- $component := "backend" -}} apiVersion: apps/v1 @@ -53,9 +53,10 @@ spec: env: {{- $envVars | indent 12 }} {{- end }} - {{- if .Values.backend.envFrom }} + {{- $envFrom := concat (.Values.backend.envFrom | default list) ((.Values.backend.django | default dict).envFrom | default list) }} + {{- if $envFrom }} envFrom: - {{- toYaml .Values.backend.envFrom | nindent 12 }} + {{- toYaml $envFrom | nindent 12 }} {{- end }} {{- with .Values.backend.securityContext }} securityContext: diff --git a/src/helm/impress/templates/celery_worker_deployment.yaml b/src/helm/impress/templates/celery_worker_deployment.yaml index 56743c4d..7c9a5c83 100644 --- a/src/helm/impress/templates/celery_worker_deployment.yaml +++ b/src/helm/impress/templates/celery_worker_deployment.yaml @@ -1,4 +1,4 @@ -{{- $envVars := include "impress.common.env" (list . .Values.backend) -}} +{{- $envVars := include "impress.backend.celery.env" (list . .Values.backend) -}} {{- $fullName := include "impress.celery.worker.fullname" . -}} {{- $component := "celery-worker" -}} apiVersion: apps/v1 @@ -53,9 +53,10 @@ spec: env: {{- $envVars | indent 12 }} {{- end }} - {{- if .Values.backend.envFrom }} + {{- $envFrom := concat (.Values.backend.envFrom | default list) (.Values.backend.celery.envFrom | default list) }} + {{- if $envFrom }} envFrom: - {{- toYaml .Values.backend.envFrom | nindent 12 }} + {{- toYaml $envFrom | nindent 12 }} {{- end }} {{- with .Values.backend.securityContext }} securityContext: diff --git a/src/helm/impress/values.yaml b/src/helm/impress/values.yaml index a3710076..c25905cb 100644 --- a/src/helm/impress/values.yaml +++ b/src/helm/impress/values.yaml @@ -243,7 +243,7 @@ backend: envVars: <<: *commonEnvVars - ## @skip backend.envFrom List of environment variables taken from Secrets or configMaps + ## @skip backend.envFrom List of environment variables taken from Secrets or configMaps, common to backend and celery worker envFrom: [] # envFrom: # - secret: @@ -251,6 +251,13 @@ backend: # - configMapRef: # name: my-environment-variables + ## @extra backend.django.envVars Backend web deployment specific environment variables (not shared with celery worker) + ## @skip backend.django.envVars + ## @skip backend.django.envFrom List of environment variables taken from Secrets or configMaps, specific to the backend web deployment + django: + envVars: {} + envFrom: [] + ## @param backend.podAnnotations Annotations to add to the backend Pod podAnnotations: {} @@ -396,6 +403,9 @@ backend: ## @param backend.celery.probes.readiness.exec.command Override the celery container readiness probe command ## @param backend.celery.probes.readiness.initialDelaySeconds Initial delay for the celery container readiness probe ## @param backend.celery.probes.readiness.timeoutSeconds Timeout for the celery container readiness probe + ## @extra backend.celery.envVars Celery worker specific environment variables (not shared with the backend web deployment) + ## @skip backend.celery.envVars + ## @skip backend.celery.envFrom List of environment variables taken from Secrets or configMaps, specific to celery worker celery: replicas: 1 command: [] @@ -410,6 +420,8 @@ backend: "-n", "impress@%h", ] + envVars: {} + envFrom: [] resources: {} probes: liveness: