You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2021/06/02 19:19:39 UTC

[airflow] branch main updated: Chart: Adds labels to Kubernetes worker pods (#16203)

This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 62178ed  Chart: Adds labels to Kubernetes worker pods (#16203)
62178ed is described below

commit 62178ed6f5b24956c282e6d2d8d6b307fd01cd79
Author: Jed Cunningham <66...@users.noreply.github.com>
AuthorDate: Wed Jun 2 13:19:17 2021 -0600

    Chart: Adds labels to Kubernetes worker pods (#16203)
    
    We want to set labels on the KubernetesExecutor worker pods as well as
    one would expect those pods to show up when, say, filtering running pods
    by release name.
---
 chart/files/pod-template-file.kubernetes-helm-yaml |  7 +++++++
 chart/tests/test_pod_template_file.py              | 15 +++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/chart/files/pod-template-file.kubernetes-helm-yaml b/chart/files/pod-template-file.kubernetes-helm-yaml
index f4f0efd..f50324b 100644
--- a/chart/files/pod-template-file.kubernetes-helm-yaml
+++ b/chart/files/pod-template-file.kubernetes-helm-yaml
@@ -19,6 +19,13 @@ apiVersion: v1
 kind: Pod
 metadata:
   name: dummy-name
+  labels:
+    tier: airflow
+    component: worker
+    release: {{ .Release.Name }}
+{{- with .Values.labels }}
+{{ toYaml . | indent 4 }}
+{{- end }}
   {{- if .Values.airflowPodAnnotations }}
   annotations:
   {{- toYaml .Values.airflowPodAnnotations | nindent 4 }}
diff --git a/chart/tests/test_pod_template_file.py b/chart/tests/test_pod_template_file.py
index 0b46f66..0ca81e8 100644
--- a/chart/tests/test_pod_template_file.py
+++ b/chart/tests/test_pod_template_file.py
@@ -438,3 +438,18 @@ class PodTemplateFileTest(unittest.TestCase):
             "name": "test-init-container",
             "image": "test-registry/test-repo:test-tag",
         } == jmespath.search("spec.initContainers[-1]", docs[0])
+
+    def test_should_add_pod_labels(self):
+        docs = render_chart(
+            values={"labels": {"label1": "value1", "label2": "value2"}},
+            show_only=["templates/pod-template-file.yaml"],
+            chart_dir=self.temp_chart_dir,
+        )
+
+        assert {
+            "label1": "value1",
+            "label2": "value2",
+            "release": "RELEASE-NAME",
+            "component": "worker",
+            "tier": "airflow",
+        } == jmespath.search("metadata.labels", docs[0])