diff --git a/chart/templates/scheduler/scheduler-deployment.yaml b/chart/templates/scheduler/scheduler-deployment.yaml index 1f23cd8bb517c..7504c37a15d3b 100644 --- a/chart/templates/scheduler/scheduler-deployment.yaml +++ b/chart/templates/scheduler/scheduler-deployment.yaml @@ -132,6 +132,10 @@ spec: imagePullSecrets: - name: {{ template "registry_secret" . }} {{- end }} +{{- if .Values.scheduler.hostAliases }} + hostAliases: +{{ toYaml .Values.scheduler.hostAliases | indent 8 }} +{{- end }} initContainers: {{- if .Values.scheduler.waitForMigrations.enabled }} - name: wait-for-airflow-migrations diff --git a/chart/templates/webserver/webserver-deployment.yaml b/chart/templates/webserver/webserver-deployment.yaml index f43d6d5400acb..23685a874f371 100644 --- a/chart/templates/webserver/webserver-deployment.yaml +++ b/chart/templates/webserver/webserver-deployment.yaml @@ -95,6 +95,10 @@ spec: {{- toYaml .Values.webserver.podAnnotations | nindent 8 }} {{- end }} spec: +{{- if .Values.webserver.hostAliases }} + hostAliases: +{{ toYaml .Values.webserver.hostAliases | indent 8 }} +{{- end }} serviceAccountName: {{ include "webserver.serviceAccountName" . }} {{- if .Values.webserver.priorityClassName }} priorityClassName: {{ .Values.webserver.priorityClassName }} diff --git a/chart/values.schema.json b/chart/values.schema.json index bd7967a727383..0879c99a17734 100644 --- a/chart/values.schema.json +++ b/chart/values.schema.json @@ -1656,6 +1656,28 @@ "x-docsSection": "Scheduler", "additionalProperties": false, "properties": { + "hostAliases": { + "description": "HostAliases for the scheduler pod.", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.HostAlias" + }, + "type": "array", + "default": [], + "examples": [ + { + "ip": "127.0.0.1", + "hostnames": [ + "foo.local" + ] + }, + { + "ip": "10.1.2.3", + "hostnames": [ + "foo.remote" + ] + } + ] + }, "livenessProbe": { "description": "Liveness probe configuration for scheduler container.", "type": "object", @@ -3108,6 +3130,28 @@ "x-docsSection": "Webserver", "additionalProperties": false, "properties": { + "hostAliases": { + "description": "HostAliases for the webserver pod.", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.HostAlias" + }, + "type": "array", + "default": [], + "examples": [ + { + "ip": "127.0.0.1", + "hostnames": [ + "foo.local" + ] + }, + { + "ip": "10.1.2.3", + "hostnames": [ + "foo.remote" + ] + } + ] + }, "allowPodLogReading": { "description": "Allow webserver to read k8s pod logs. Useful when you don't have an external log store.", "type": "boolean", diff --git a/chart/values.yaml b/chart/values.yaml index 51d162c5d9c97..f86ba33c25539 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -636,6 +636,15 @@ workers: # Airflow scheduler settings scheduler: + # hostAliases for the scheduler pod + hostAliases: [] + # - ip: "127.0.0.1" + # hostnames: + # - "foo.local" + # - ip: "10.1.2.3" + # hostnames: + # - "foo.remote" + # If the scheduler stops heartbeating for 5 minutes (5*60s) kill the # scheduler and let Kubernetes restart it livenessProbe: @@ -900,6 +909,14 @@ migrateDatabaseJob: # Airflow webserver settings webserver: + # hostAliases for the webserver pod + hostAliases: [] + # - ip: "127.0.0.1" + # hostnames: + # - "foo.local" + # - ip: "10.1.2.3" + # hostnames: + # - "foo.remote" allowPodLogReading: true livenessProbe: initialDelaySeconds: 15 diff --git a/tests/charts/test_scheduler.py b/tests/charts/test_scheduler.py index 1ae14e4048d7a..dbf8161f6057c 100644 --- a/tests/charts/test_scheduler.py +++ b/tests/charts/test_scheduler.py @@ -623,6 +623,19 @@ def test_should_add_component_specific_annotations(self): assert "annotations" in jmespath.search("metadata", docs[0]) assert jmespath.search("metadata.annotations", docs[0])["test_annotation"] == "test_annotation_value" + def test_scheduler_pod_hostaliases(self): + docs = render_chart( + values={ + "scheduler": { + "hostAliases": [{"ip": "127.0.0.1", "hostnames": ["foo.local"]}], + }, + }, + show_only=["templates/scheduler/scheduler-deployment.yaml"], + ) + + assert "127.0.0.1" == jmespath.search("spec.template.spec.hostAliases[0].ip", docs[0]) + assert "foo.local" == jmespath.search("spec.template.spec.hostAliases[0].hostnames[0]", docs[0]) + class TestSchedulerNetworkPolicy: def test_should_add_component_specific_labels(self): diff --git a/tests/charts/test_webserver.py b/tests/charts/test_webserver.py index 1b0d49b0f3984..06b0de62d2f39 100644 --- a/tests/charts/test_webserver.py +++ b/tests/charts/test_webserver.py @@ -685,6 +685,19 @@ def test_should_add_component_specific_annotations(self): assert "annotations" in jmespath.search("metadata", docs[0]) assert jmespath.search("metadata.annotations", docs[0])["test_annotation"] == "test_annotation_value" + def test_webserver_pod_hostaliases(self): + docs = render_chart( + values={ + "webserver": { + "hostAliases": [{"ip": "127.0.0.1", "hostnames": ["foo.local"]}], + }, + }, + show_only=["templates/webserver/webserver-deployment.yaml"], + ) + + assert "127.0.0.1" == jmespath.search("spec.template.spec.hostAliases[0].ip", docs[0]) + assert "foo.local" == jmespath.search("spec.template.spec.hostAliases[0].hostnames[0]", docs[0]) + class TestWebserverService: def test_default_service(self):