From af76bdde11ce76d41b483f2dde2ae0656e1d8ad7 Mon Sep 17 00:00:00 2001 From: Miretpl Date: Sat, 11 Apr 2026 13:51:19 +0200 Subject: [PATCH 1/2] Add workers.celery.env & workers.kubernetes.env --- .../pod-template-file.kubernetes-helm-yaml | 2 +- chart/templates/NOTES.txt | 8 ++ chart/values.schema.json | 116 +++++++++++++++++- chart/values.yaml | 7 ++ .../airflow_aux/test_pod_template_file.py | 44 ++++++- .../helm_tests/airflow_core/test_worker.py | 46 ++++++- .../airflow_core/test_worker_sets.py | 7 ++ 7 files changed, 220 insertions(+), 10 deletions(-) diff --git a/chart/files/pod-template-file.kubernetes-helm-yaml b/chart/files/pod-template-file.kubernetes-helm-yaml index 6449fe329ad88..26b1b8505d0c1 100644 --- a/chart/files/pod-template-file.kubernetes-helm-yaml +++ b/chart/files/pod-template-file.kubernetes-helm-yaml @@ -120,7 +120,7 @@ spec: {{- end }} {{- include "standard_airflow_environment" . | indent 6}} {{- include "custom_airflow_environment" . | indent 6 }} - {{- include "container_extra_envs" (list . .Values.workers.env) | indent 6 }} + {{- include "container_extra_envs" (list . (.Values.workers.kubernetes.env | default .Values.workers.env)) | indent 6 }} image: {{ template "pod_template_image" . }} imagePullPolicy: {{ .Values.images.pod_template.pullPolicy }} securityContext: {{ $containerSecurityContext | nindent 8 }} diff --git a/chart/templates/NOTES.txt b/chart/templates/NOTES.txt index b5038eaa55fd4..57d94edf22cb7 100644 --- a/chart/templates/NOTES.txt +++ b/chart/templates/NOTES.txt @@ -957,6 +957,14 @@ DEPRECATION WARNING: {{- end }} +{{- if not (empty .Values.workers.env) }} + + DEPRECATION WARNING: + `workers.env` has been renamed to `workers.celery.env`/`workers.kubernetes.env`. + Please change your values as support for the old name will be dropped in a future release. + +{{- end }} + {{- if not (empty .Values.webserver.defaultUser) }} DEPRECATION WARNING: diff --git a/chart/values.schema.json b/chart/values.schema.json index 658de692e9b58..da245664137fd 100644 --- a/chart/values.schema.json +++ b/chart/values.schema.json @@ -2719,7 +2719,7 @@ } }, "env": { - "description": "Add additional env vars to the Airflow Celery workers and pods created with pod-template-file.", + "description": "Add additional env vars to the Airflow Celery workers and pods created with pod-template-file (deprecated, use ``workers.celery.env`` and/or ``workers.kubernetes.env`` instead).", "type": "array", "default": [], "items": { @@ -3877,6 +3877,63 @@ } } }, + "env": { + "description": "Add additional env vars to the Airflow Celery workers.", + "type": "array", + "default": [], + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + }, + "valueFrom": { + "type": "object", + "properties": { + "configMapKeyRef": { + "$ref": "#/definitions/io.k8s.api.core.v1.ConfigMapKeySelector", + "description": "Selects a key of a ConfigMap." + }, + "secretKeyRef": { + "$ref": "#/definitions/io.k8s.api.core.v1.SecretKeySelector", + "description": "Selects a key of a secret in the pod's namespace" + } + }, + "anyOf": [ + { + "required": [ + "configMapKeyRef" + ] + }, + { + "required": [ + "secretKeyRef" + ] + } + ] + } + }, + "required": [ + "name" + ], + "anyOf": [ + { + "required": [ + "value" + ] + }, + { + "required": [ + "valueFrom" + ] + } + ], + "additionalProperties": false + } + }, "volumeClaimTemplates": { "description": "Specify additional volume claim template for Airflow Celery workers.", "type": "array", @@ -4365,6 +4422,63 @@ "type": "string" } }, + "env": { + "description": "Add additional env vars to the pods created with pod-template-file.", + "type": "array", + "default": [], + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + }, + "valueFrom": { + "type": "object", + "properties": { + "configMapKeyRef": { + "$ref": "#/definitions/io.k8s.api.core.v1.ConfigMapKeySelector", + "description": "Selects a key of a ConfigMap." + }, + "secretKeyRef": { + "$ref": "#/definitions/io.k8s.api.core.v1.SecretKeySelector", + "description": "Selects a key of a secret in the pod's namespace" + } + }, + "anyOf": [ + { + "required": [ + "configMapKeyRef" + ] + }, + { + "required": [ + "secretKeyRef" + ] + } + ] + } + }, + "required": [ + "name" + ], + "anyOf": [ + { + "required": [ + "value" + ] + }, + { + "required": [ + "valueFrom" + ] + } + ], + "additionalProperties": false + } + }, "schedulerName": { "description": "Specify kube scheduler name for pods created with pod-template-file.", "type": [ diff --git a/chart/values.yaml b/chart/values.yaml index e9f7876450bdd..3bdf20b516154 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -1220,6 +1220,7 @@ workers: container: {} # Additional env variable configuration for Airflow Celery workers and pods created with pod-template-file + # (deprecated, use `workers.celery.env` and/or `workers.kubernetes.env` instead) env: [] # Additional volume claim templates for Airflow Celery workers. @@ -1612,6 +1613,9 @@ workers: securityContexts: container: {} + # Additional env variable configuration for Airflow Celery workers + env: [] + # Additional volume claim templates for Airflow Celery workers. # Requires mounting of specified volumes under extraVolumeMounts. volumeClaimTemplates: [] @@ -1787,6 +1791,9 @@ workers: # Labels specific to pods created with pod-template-file labels: {} + # Additional env variable configuration for pods created with pod-template-file + env: [] + schedulerName: ~ # Airflow scheduler settings diff --git a/helm-tests/tests/helm_tests/airflow_aux/test_pod_template_file.py b/helm-tests/tests/helm_tests/airflow_aux/test_pod_template_file.py index 55a1fb94d4c4b..45b4570047152 100644 --- a/helm-tests/tests/helm_tests/airflow_aux/test_pod_template_file.py +++ b/helm-tests/tests/helm_tests/airflow_aux/test_pod_template_file.py @@ -1339,10 +1339,24 @@ def test_should_add_pod_labels(self): "tier": "airflow", } - def test_should_add_extraEnvs(self): - docs = render_chart( - values={ - "workers": { + @pytest.mark.parametrize( + "workers_values", + [ + { + "env": [ + {"name": "TEST_ENV_1", "value": "test_env_1"}, + { + "name": "TEST_ENV_2", + "valueFrom": {"secretKeyRef": {"name": "my-secret", "key": "my-key"}}, + }, + { + "name": "TEST_ENV_3", + "valueFrom": {"configMapKeyRef": {"name": "my-config-map", "key": "my-key"}}, + }, + ] + }, + { + "kubernetes": { "env": [ {"name": "TEST_ENV_1", "value": "test_env_1"}, { @@ -1356,6 +1370,27 @@ def test_should_add_extraEnvs(self): ] } }, + { + "env": [{"name": "TEST", "value": "test"}], + "kubernetes": { + "env": [ + {"name": "TEST_ENV_1", "value": "test_env_1"}, + { + "name": "TEST_ENV_2", + "valueFrom": {"secretKeyRef": {"name": "my-secret", "key": "my-key"}}, + }, + { + "name": "TEST_ENV_3", + "valueFrom": {"configMapKeyRef": {"name": "my-config-map", "key": "my-key"}}, + }, + ] + }, + }, + ], + ) + def test_should_add_extraEnvs(self, workers_values): + docs = render_chart( + values={"workers": workers_values}, show_only=["templates/pod-template-file.yaml"], chart_dir=self.temp_chart_dir, ) @@ -1363,6 +1398,7 @@ def test_should_add_extraEnvs(self): assert {"name": "TEST_ENV_1", "value": "test_env_1"} in jmespath.search( "spec.containers[0].env", docs[0] ) + assert {"name": "TEST", "value": "test"} not in jmespath.search("spec.containers[0].env", docs[0]) assert { "name": "TEST_ENV_2", "valueFrom": {"secretKeyRef": {"name": "my-secret", "key": "my-key"}}, diff --git a/helm-tests/tests/helm_tests/airflow_core/test_worker.py b/helm-tests/tests/helm_tests/airflow_core/test_worker.py index 10124a2500873..3e31d2d454efe 100644 --- a/helm-tests/tests/helm_tests/airflow_core/test_worker.py +++ b/helm-tests/tests/helm_tests/airflow_core/test_worker.py @@ -418,10 +418,40 @@ def test_should_add_global_volume_and_global_volume_mount(self): jmespath.search("spec.template.spec.containers[0].volumeMounts[0].name", docs[0]) == "test-volume" ) - def test_should_add_extraEnvs(self): - docs = render_chart( - values={ - "workers": { + @pytest.mark.parametrize( + "workers_values", + [ + { + "env": [ + {"name": "TEST_ENV_1", "value": "test_env_1"}, + { + "name": "TEST_ENV_2", + "valueFrom": {"secretKeyRef": {"name": "my-secret", "key": "my-key"}}, + }, + { + "name": "TEST_ENV_3", + "valueFrom": {"configMapKeyRef": {"name": "my-config-map", "key": "my-key"}}, + }, + ], + }, + { + "celery": { + "env": [ + {"name": "TEST_ENV_1", "value": "test_env_1"}, + { + "name": "TEST_ENV_2", + "valueFrom": {"secretKeyRef": {"name": "my-secret", "key": "my-key"}}, + }, + { + "name": "TEST_ENV_3", + "valueFrom": {"configMapKeyRef": {"name": "my-config-map", "key": "my-key"}}, + }, + ], + } + }, + { + "env": [{"name": "TEST", "value": "test"}], + "celery": { "env": [ {"name": "TEST_ENV_1", "value": "test_env_1"}, { @@ -435,12 +465,20 @@ def test_should_add_extraEnvs(self): ], }, }, + ], + ) + def test_should_add_extraEnvs(self, workers_values): + docs = render_chart( + values={"workers": workers_values}, show_only=["templates/workers/worker-deployment.yaml"], ) assert {"name": "TEST_ENV_1", "value": "test_env_1"} in jmespath.search( "spec.template.spec.containers[0].env", docs[0] ) + assert {"name": "TEST", "value": "test"} not in jmespath.search( + "spec.template.spec.containers[0].env", docs[0] + ) assert { "name": "TEST_ENV_2", "valueFrom": {"secretKeyRef": {"name": "my-secret", "key": "my-key"}}, diff --git a/helm-tests/tests/helm_tests/airflow_core/test_worker_sets.py b/helm-tests/tests/helm_tests/airflow_core/test_worker_sets.py index 74bb2f6334221..a2695fe39e419 100644 --- a/helm-tests/tests/helm_tests/airflow_core/test_worker_sets.py +++ b/helm-tests/tests/helm_tests/airflow_core/test_worker_sets.py @@ -3362,6 +3362,13 @@ def test_overwrite_wait_for_migration_security_context_container(self, workers_v "sets": [{"name": "set1", "env": [{"name": "TEST_ENV_1", "value": "test_env_1"}]}], }, }, + { + "celery": { + "enableDefault": False, + "env": [{"name": "TEST", "value": "test"}], + "sets": [{"name": "set1", "env": [{"name": "TEST_ENV_1", "value": "test_env_1"}]}], + }, + }, ], ) def test_overwrite_env(self, workers_values): From 8b9281d1929c1da052f06127779374610dab4f12 Mon Sep 17 00:00:00 2001 From: Miretpl Date: Sat, 11 Apr 2026 13:53:20 +0200 Subject: [PATCH 2/2] Add newsfragment --- chart/newsfragments/65056.significant.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 chart/newsfragments/65056.significant.rst diff --git a/chart/newsfragments/65056.significant.rst b/chart/newsfragments/65056.significant.rst new file mode 100644 index 0000000000000..6e919a246200e --- /dev/null +++ b/chart/newsfragments/65056.significant.rst @@ -0,0 +1 @@ +``workers.env`` field is now deprecated in favor of ``workers.celery.env`` and ``workers.kubernetes.env``. Please update your configuration accordingly.