This is an automated email from the ASF dual-hosted git repository.
jscheffl pushed a commit to branch chart/v1-2x-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/chart/v1-2x-test by this push:
new 1c3ec8ab662 [chart/v1-2x-test] Add workers.celery.affinity &
workers.kubernetes.affinity (#64860) (#64910)
1c3ec8ab662 is described below
commit 1c3ec8ab662534fb11187772c9ba1af29759ccba
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Apr 8 19:20:14 2026 +0200
[chart/v1-2x-test] Add workers.celery.affinity &
workers.kubernetes.affinity (#64860) (#64910)
* Add workers.celery.affinity & workers.kubernetes.affinity
* Add newsfragment
(cherry picked from commit c35d1d77fa2b1725a0e7ed7d33b9b0ea0f2313a8)
Co-authored-by: Przemysław Mirowski
<[email protected]>
---
chart/files/pod-template-file.kubernetes-helm-yaml | 2 +-
chart/newsfragments/64860.significant.rst | 1 +
chart/templates/NOTES.txt | 8 +++
chart/values.schema.json | 14 ++++-
chart/values.yaml | 14 +++++
.../airflow_aux/test_pod_template_file.py | 63 ++++++++++++++++++++--
.../tests/helm_tests/airflow_core/test_worker.py | 63 ++++++++++++++++++++--
.../helm_tests/airflow_core/test_worker_sets.py | 37 +++++++++++++
8 files changed, 190 insertions(+), 12 deletions(-)
diff --git a/chart/files/pod-template-file.kubernetes-helm-yaml
b/chart/files/pod-template-file.kubernetes-helm-yaml
index 5f067c68077..5aae2d8fc94 100644
--- a/chart/files/pod-template-file.kubernetes-helm-yaml
+++ b/chart/files/pod-template-file.kubernetes-helm-yaml
@@ -18,7 +18,7 @@
*/}}
---
{{- $nodeSelector := or .Values.workers.kubernetes.nodeSelector
.Values.workers.nodeSelector .Values.nodeSelector }}
-{{- $affinity := or .Values.workers.affinity .Values.affinity }}
+{{- $affinity := or .Values.workers.kubernetes.affinity
.Values.workers.affinity .Values.affinity }}
{{- $tolerations := or .Values.workers.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.workers.topologySpreadConstraints
.Values.topologySpreadConstraints }}
{{- $securityContext := include "airflowPodSecurityContext" (list
.Values.workers.kubernetes .Values.workers .Values) }}
diff --git a/chart/newsfragments/64860.significant.rst
b/chart/newsfragments/64860.significant.rst
new file mode 100644
index 00000000000..672bd787a51
--- /dev/null
+++ b/chart/newsfragments/64860.significant.rst
@@ -0,0 +1 @@
+``workers.affinity`` field is now deprecated in favor of
``workers.celery.affinity`` and ``workers.kubernetes.affinity``. Please update
your configuration accordingly.
diff --git a/chart/templates/NOTES.txt b/chart/templates/NOTES.txt
index 44924918060..7728d1654f7 100644
--- a/chart/templates/NOTES.txt
+++ b/chart/templates/NOTES.txt
@@ -717,6 +717,14 @@ DEPRECATION WARNING:
{{- end }}
+{{- if not (empty .Values.workers.affinity) }}
+
+ DEPRECATION WARNING:
+ `workers.affinity` has been renamed to
`workers.celery.affinity`/`workers.kubernetes.affinity`.
+ Please change your values as support for the old name will be dropped in a
future release.
+
+{{- end }}
+
{{- if not (empty .Values.workers.nodeSelector) }}
DEPRECATION WARNING:
diff --git a/chart/values.schema.json b/chart/values.schema.json
index 97fadd3385e..a67e56b35af 100644
--- a/chart/values.schema.json
+++ b/chart/values.schema.json
@@ -2357,7 +2357,7 @@
"default": null
},
"affinity": {
- "description": "Specify scheduling constraints for Airflow
Celery worker pods and pods created with pod-template-file.",
+ "description": "Specify scheduling constraints for Airflow
Celery worker pods and pods created with pod-template-file (deprecated, use
``workers.celery.affinity`` and/or ``workers.kubernetes.affinity`` instead).",
"type": "object",
"default": "See values.yaml",
"$ref": "#/definitions/io.k8s.api.core.v1.Affinity"
@@ -3412,6 +3412,12 @@
],
"default": null
},
+ "affinity": {
+ "description": "Specify scheduling constraints for
Airflow Celery worker pods.",
+ "type": "object",
+ "default": {},
+ "$ref": "#/definitions/io.k8s.api.core.v1.Affinity"
+ },
"hostAliases": {
"description": "Specify HostAliases for Airflow
Celery worker pods.",
"items": {
@@ -3888,6 +3894,12 @@
],
"default": null
},
+ "affinity": {
+ "description": "Specify scheduling constraints for
pods created with pod-template-file.",
+ "type": "object",
+ "default": {},
+ "$ref": "#/definitions/io.k8s.api.core.v1.Affinity"
+ },
"hostAliases": {
"description": "Specify HostAliases for pods
created with pod-template-file.",
"items": {
diff --git a/chart/values.yaml b/chart/values.yaml
index 2510e3506e4..651a6779aea 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -1081,6 +1081,7 @@ workers:
# (deprecated, use `workers.celery.priorityClassName` and/or
`workers.kubernetes.priorityClassName` instead)
priorityClassName: ~
+ # (deprecated, use `workers.celery.affinity` and/or
`workers.kubernetes.affinity` instead)
affinity: {}
# Default Airflow Celery worker affinity is:
# podAntiAffinity:
@@ -1452,6 +1453,17 @@ workers:
priorityClassName: ~
+ affinity: {}
+ # Default Airflow Celery worker affinity is:
+ # podAntiAffinity:
+ # preferredDuringSchedulingIgnoredDuringExecution:
+ # - podAffinityTerm:
+ # labelSelector:
+ # matchLabels:
+ # component: worker
+ # topologyKey: kubernetes.io/hostname
+ # weight: 100
+
# hostAliases to use in Airflow Celery worker pods
# See:
#
https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/
@@ -1600,6 +1612,8 @@ workers:
priorityClassName: ~
+ affinity: {}
+
# hostAliases to use in pods created with pod-template-file
# See:
#
https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/
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 d206f61c085..376c3f25ff2 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
@@ -462,11 +462,56 @@ class TestPodTemplateFile:
assert jmespath.search("kind", docs[0]) == "Pod"
assert jmespath.search("spec.nodeSelector", docs[0]) == {"diskType":
"ssd"}
- def test_workers_affinity(self):
- docs = render_chart(
- values={
- "executor": "KubernetesExecutor",
- "workers": {
+ @pytest.mark.parametrize(
+ "workers_values",
+ [
+ {
+ "affinity": {
+ "nodeAffinity": {
+ "requiredDuringSchedulingIgnoredDuringExecution": {
+ "nodeSelectorTerms": [
+ {
+ "matchExpressions": [
+ {"key": "foo", "operator": "In",
"values": ["true"]},
+ ]
+ }
+ ]
+ }
+ }
+ },
+ },
+ {
+ "kubernetes": {
+ "affinity": {
+ "nodeAffinity": {
+ "requiredDuringSchedulingIgnoredDuringExecution": {
+ "nodeSelectorTerms": [
+ {
+ "matchExpressions": [
+ {"key": "foo", "operator": "In",
"values": ["true"]},
+ ]
+ }
+ ]
+ }
+ }
+ },
+ }
+ },
+ {
+ "affinity": {
+ "podAffinity": {
+ "preferredDuringSchedulingIgnoredDuringExecution": [
+ {
+ "podAffinityTerm": {
+ "topologyKey": "foo",
+ "labelSelector": {"matchLabels": {"tier":
"airflow"}},
+ },
+ "weight": 1,
+ }
+ ]
+ }
+ },
+ "kubernetes": {
"affinity": {
"nodeAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": {
@@ -482,6 +527,14 @@ class TestPodTemplateFile:
},
},
},
+ ],
+ )
+ def test_workers_affinity(self, workers_values):
+ docs = render_chart(
+ values={
+ "executor": "KubernetesExecutor",
+ "workers": workers_values,
+ },
show_only=["templates/pod-template-file.yaml"],
chart_dir=self.temp_chart_dir,
)
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 50975cceefe..03764d3d9e3 100644
--- a/helm-tests/tests/helm_tests/airflow_core/test_worker.py
+++ b/helm-tests/tests/helm_tests/airflow_core/test_worker.py
@@ -510,11 +510,56 @@ class TestWorker:
assert expected_strategy == jmespath.search("spec.strategy", docs[0])
- def test_affinity(self):
- docs = render_chart(
- values={
- "executor": "CeleryExecutor",
- "workers": {
+ @pytest.mark.parametrize(
+ "workers_values",
+ [
+ {
+ "affinity": {
+ "nodeAffinity": {
+ "requiredDuringSchedulingIgnoredDuringExecution": {
+ "nodeSelectorTerms": [
+ {
+ "matchExpressions": [
+ {"key": "foo", "operator": "In",
"values": ["true"]},
+ ]
+ }
+ ]
+ }
+ }
+ },
+ },
+ {
+ "celery": {
+ "affinity": {
+ "nodeAffinity": {
+ "requiredDuringSchedulingIgnoredDuringExecution": {
+ "nodeSelectorTerms": [
+ {
+ "matchExpressions": [
+ {"key": "foo", "operator": "In",
"values": ["true"]},
+ ]
+ }
+ ]
+ }
+ }
+ },
+ }
+ },
+ {
+ "affinity": {
+ "podAffinity": {
+ "preferredDuringSchedulingIgnoredDuringExecution": [
+ {
+ "podAffinityTerm": {
+ "topologyKey": "foo",
+ "labelSelector": {"matchLabels": {"tier":
"airflow"}},
+ },
+ "weight": 1,
+ }
+ ]
+ }
+ },
+ "celery": {
"affinity": {
"nodeAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": {
@@ -530,6 +575,14 @@ class TestWorker:
},
},
},
+ ],
+ )
+ def test_affinity(self, workers_values):
+ docs = render_chart(
+ values={
+ "executor": "CeleryExecutor",
+ "workers": workers_values,
+ },
show_only=["templates/workers/worker-deployment.yaml"],
)
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 18edc03c6c2..a77d78eb91c 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
@@ -2791,6 +2791,43 @@ class TestWorkerSets:
],
},
},
+ {
+ "celery": {
+ "enableDefault": False,
+ "affinity": {
+ "podAffinity": {
+ "preferredDuringSchedulingIgnoredDuringExecution":
[
+ {
+ "podAffinityTerm": {
+ "topologyKey": "foo",
+ "labelSelector": {"matchLabels":
{"tier": "airflow"}},
+ },
+ "weight": 1,
+ }
+ ]
+ }
+ },
+ "sets": [
+ {
+ "name": "set1",
+ "affinity": {
+ "nodeAffinity": {
+
"preferredDuringSchedulingIgnoredDuringExecution": [
+ {
+ "weight": 1,
+ "preference": {
+ "matchExpressions": [
+ {"key": "not-me",
"operator": "In", "values": ["true"]},
+ ]
+ },
+ }
+ ]
+ }
+ },
+ }
+ ],
+ },
+ },
],
)
def test_overwrite_affinity(self, workers_values):