From 898c5785a5d07d8fc95f2a004c8485c06b7da629 Mon Sep 17 00:00:00 2001 From: aakcht Date: Mon, 7 Nov 2022 15:58:42 +0300 Subject: [PATCH] Chart: add hostaliases to pod template file --- chart/files/pod-template-file.kubernetes-helm-yaml | 4 ++++ tests/charts/test_pod_template_file.py | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/chart/files/pod-template-file.kubernetes-helm-yaml b/chart/files/pod-template-file.kubernetes-helm-yaml index f59af3d0ea6cd..dac3ae1c4ead0 100644 --- a/chart/files/pod-template-file.kubernetes-helm-yaml +++ b/chart/files/pod-template-file.kubernetes-helm-yaml @@ -90,6 +90,10 @@ spec: imagePullSecrets: - name: {{ template "registry_secret" . }} {{- end }} +{{- if .Values.workers.hostAliases }} + hostAliases: +{{ toYaml .Values.workers.hostAliases | indent 4 }} +{{- end }} restartPolicy: Never securityContext: {{ $securityContext | nindent 4 }} nodeSelector: {{ toYaml $nodeSelector | nindent 4 }} diff --git a/tests/charts/test_pod_template_file.py b/tests/charts/test_pod_template_file.py index 722b69eae1319..fa5a9128c068f 100644 --- a/tests/charts/test_pod_template_file.py +++ b/tests/charts/test_pod_template_file.py @@ -704,3 +704,17 @@ def test_empty_resources(self): chart_dir=self.temp_chart_dir, ) assert {} == jmespath.search("spec.containers[0].resources", docs[0]) + + def test_workers_host_aliases(self): + docs = render_chart( + values={ + "workers": { + "hostAliases": [{"ip": "127.0.0.2", "hostnames": ["test.hostname"]}], + }, + }, + show_only=["templates/pod-template-file.yaml"], + chart_dir=self.temp_chart_dir, + ) + + assert "127.0.0.2" == jmespath.search("spec.hostAliases[0].ip", docs[0]) + assert "test.hostname" == jmespath.search("spec.hostAliases[0].hostnames[0]", docs[0])