Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds labels to k8s worker pods #16203

Merged
merged 1 commit into from
Jun 2, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions chart/files/pod-template-file.kubernetes-helm-yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ apiVersion: v1
kind: Pod
metadata:
name: dummy-name
labels:
tier: airflow
component: worker
release: {{ .Release.Name }}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't set the chart label, however, as it felt odd given the scheduler is creating these. I'm happy to add it if others think we should.

{{- with .Values.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
{{- if .Values.airflowPodAnnotations }}
annotations:
{{- toYaml .Values.airflowPodAnnotations | nindent 4 }}
Expand Down
15 changes: 15 additions & 0 deletions chart/tests/test_pod_template_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,18 @@ def test_should_add_extra_init_containers(self):
"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])