Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions chart/docs/customizing-labels.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ You can also set specific labels for individual Airflow components, which will b
If the same label key exists in both global and component-specific labels, the component-specific value takes precedence (overrides the global value).

This allows you to customize labels for specific components while still maintaining common global labels across all resources.
For example, to add specific labels to different components:
For example, to add specific labels to different components like scheduler or api-server:

.. code-block:: yaml
:caption: values.yaml
Expand All @@ -56,11 +56,6 @@ For example, to add specific labels to different components:
labels:
role: scheduler

# Worker specific labels
workers:
labels:
role: worker

# API Server specific labels
apiServer:
labels:
Expand Down
4 changes: 2 additions & 2 deletions chart/files/pod-template-file.kubernetes-helm-yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ metadata:
tier: airflow
component: worker
release: {{ .Release.Name }}
{{- if or (.Values.labels) (.Values.workers.labels) }}
{{- mustMerge .Values.workers.labels .Values.labels | toYaml | nindent 4 }}
{{- if or .Values.labels .Values.workers.labels .Values.workers.kubernetes.labels }}
{{- mustMerge (.Values.workers.kubernetes.labels | default .Values.workers.labels) .Values.labels | toYaml | nindent 4 }}
{{- end }}
annotations:
{{- tpl (toYaml $podAnnotations) . | nindent 4 }}
Expand Down
1 change: 1 addition & 0 deletions chart/newsfragments/65030.significant.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``workers.labels`` field is now deprecated in favor of ``workers.celery.labels`` and ``workers.kubernetes.labels``. Please update your configuration accordingly.
8 changes: 8 additions & 0 deletions chart/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,14 @@ DEPRECATION WARNING:

{{- end }}

{{- if not (empty .Values.workers.labels) }}

DEPRECATION WARNING:
`workers.labels` has been renamed to `workers.celery.labels`/`workers.kubernetes.labels`.
Please change your values as support for the old name will be dropped in a future release.

{{- end }}

{{- if not (empty .Values.workers.volumeClaimTemplates) }}

DEPRECATION WARNING:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ metadata:
release: {{ .Release.Name }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service }}
{{- if or .Values.labels .Values.workers.labels }}
{{- mustMerge .Values.workers.labels .Values.labels | toYaml | nindent 4 }}
{{- if or .Values.labels .Values.workers.labels .Values.workers.kubernetes.labels }}
{{- mustMerge (.Values.workers.kubernetes.labels | default .Values.workers.labels) .Values.labels | toYaml | nindent 4 }}
{{- end }}
{{- with (.Values.workers.kubernetes.serviceAccount.annotations | default .Values.workers.serviceAccount.annotations) }}
annotations: {{- toYaml . | nindent 4 }}
Expand Down
18 changes: 17 additions & 1 deletion chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2428,7 +2428,7 @@
"x-docsSection": "Common"
},
"labels": {
"description": "Labels to add to the Airflow Celery workers objects and pods created with pod-template-file.",
"description": "Labels to add to the Airflow Celery workers objects and pods created with pod-template-file (deprecated, use ``workers.celery.labels`` and/or ``workers.kubernetes.labels`` instead).",
"type": "object",
"default": {},
"additionalProperties": {
Expand Down Expand Up @@ -3648,6 +3648,14 @@
"type": "string"
}
},
"labels": {
"description": "Labels to add to the Airflow Celery workers objects.",
"type": "object",
"default": {},
"additionalProperties": {
"type": "string"
}
},
"logGroomerSidecar": {
"description": "Configuration for Airflow Celery worker log groomer sidecar.",
"type": "object",
Expand Down Expand Up @@ -4349,6 +4357,14 @@
"type": "string"
}
},
"labels": {
"description": "Labels to add to the pods created with pod-template-file.",
"type": "object",
"default": {},
"additionalProperties": {
"type": "string"
}
},
"schedulerName": {
"description": "Specify kube scheduler name for pods created with pod-template-file.",
"type": [
Expand Down
7 changes: 7 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,7 @@ workers:
podAnnotations: {}

# Labels specific to Airflow Celery workers objects and pods created with pod-template-file
# (deprecated, use `workers.celery.labels` and/or `workers.kubernetes.labels` instead)
labels: {}

# Log groomer configuration for Airflow Celery workers
Expand Down Expand Up @@ -1550,6 +1551,9 @@ workers:
# Pod annotations for the Airflow Celery workers (templated)
podAnnotations: {}

# Labels specific to Airflow Celery workers objects
labels: {}

# Log groomer configuration for Airflow Celery workers
logGroomerSidecar:
# Whether to deploy the Airflow Celery worker log groomer sidecar
Expand Down Expand Up @@ -1778,6 +1782,9 @@ workers:
# Pod annotations for the pods created with pod-template-file (templated)
podAnnotations: {}

# Labels specific to pods created with pod-template-file
labels: {}

schedulerName: ~

# Airflow scheduler settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1372,20 +1372,38 @@ def test_should_add_extraEnvs(self):
"valueFrom": {"configMapKeyRef": {"name": "my-config-map", "key": "my-key"}},
} in jmespath.search("spec.containers[0].env", docs[0])

def test_should_add_component_specific_labels(self):
@pytest.mark.parametrize(
"workers_values",
[
{
"labels": {"test_label": "test_label_value"},
},
{
"kubernetes": {
"labels": {"test_label": "test_label_value"},
}
},
{
"labels": {"key": "value"},
"kubernetes": {
"labels": {"test_label": "test_label_value"},
},
},
],
)
def test_should_add_component_specific_labels(self, workers_values):
docs = render_chart(
values={
"executor": "KubernetesExecutor",
"workers": {
"labels": {"test_label": "test_label_value"},
},
"workers": workers_values,
},
show_only=["templates/pod-template-file.yaml"],
chart_dir=self.temp_chart_dir,
)

assert "test_label" in jmespath.search("metadata.labels", docs[0])
assert jmespath.search("metadata.labels", docs[0])["test_label"] == "test_label_value"
labels = jmespath.search("metadata.labels", docs[0])
assert labels["test_label"] == "test_label_value"
assert "key" not in labels

@pytest.mark.parametrize(
"workers_values",
Expand Down
31 changes: 22 additions & 9 deletions helm-tests/tests/helm_tests/airflow_core/test_pdb_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,35 @@ def test_pod_disruption_budget_name(self, workers_values):
@pytest.mark.parametrize(
"workers_values",
[
{"podDisruptionBudget": {"enabled": True}},
{"celery": {"podDisruptionBudget": {"enabled": True}}},
{"podDisruptionBudget": {"enabled": True}, "labels": {"test_label": "test_label_value"}},
{
"celery": {"podDisruptionBudget": {"enabled": True}},
"labels": {"test_label": "test_label_value"},
},
{
"celery": {
"podDisruptionBudget": {"enabled": True},
"labels": {"test_label": "test_label_value"},
}
},
{
"labels": {"key": "value"},
"celery": {
"podDisruptionBudget": {"enabled": True},
"labels": {"test_label": "test_label_value"},
},
},
],
)
def test_should_add_component_specific_labels(self, workers_values):
docs = render_chart(
values={
"workers": {
**workers_values,
"labels": {"test_label": "test_label_value"},
},
},
values={"workers": workers_values},
show_only=["templates/workers/worker-poddisruptionbudget.yaml"],
)

assert jmespath.search("metadata.labels", docs[0])["test_label"] == "test_label_value"
labels = jmespath.search("metadata.labels", docs[0])
assert labels["test_label"] == "test_label_value"
assert "key" not in labels

@pytest.mark.parametrize(
"workers_values",
Expand Down
Loading
Loading