This is an automated email from the ASF dual-hosted git repository.
potiuk 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 2976a56f85 Allow templating webserver ingress hostnames (#33142)
2976a56f85 is described below
commit 2976a56f8531d3ef9782ba251911e7c7f474eda1
Author: Kim Minwoo <[email protected]>
AuthorDate: Mon Aug 14 16:12:07 2023 +0900
Allow templating webserver ingress hostnames (#33142)
---
chart/templates/webserver/webserver-ingress.yaml | 2 +-
chart/values.yaml | 1 +
helm_tests/webserver/test_ingress_web.py | 33 ++++++++++++++++++++++++
3 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/chart/templates/webserver/webserver-ingress.yaml
b/chart/templates/webserver/webserver-ingress.yaml
index 45ad6c036e..0f6b1d82d0 100644
--- a/chart/templates/webserver/webserver-ingress.yaml
+++ b/chart/templates/webserver/webserver-ingress.yaml
@@ -101,7 +101,7 @@ spec:
{{- $hostname = .name -}}
{{- end }}
{{- if $hostname }}
- host: {{ $hostname | quote }}
+ host: {{ include "common.tplvalues.render" ( dict "value" $hostname
"context" $ ) | quote }}
{{- end }}
{{- end }}
{{- if .Values.ingress.web.ingressClassName }}
diff --git a/chart/values.yaml b/chart/values.yaml
index f0edd2861b..9728eb9525 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -140,6 +140,7 @@ ingress:
# The hostnames or hosts configuration for the web Ingress
hosts: []
+ # # The hostname for the web Ingress (can be templated)
# - name: ""
# # configs for web Ingress TLS
# tls:
diff --git a/helm_tests/webserver/test_ingress_web.py
b/helm_tests/webserver/test_ingress_web.py
index b90eee352d..798da6c719 100644
--- a/helm_tests/webserver/test_ingress_web.py
+++ b/helm_tests/webserver/test_ingress_web.py
@@ -167,3 +167,36 @@ class TestIngressWeb:
)
assert "test_label" in jmespath.search("metadata.labels", docs[0])
assert jmespath.search("metadata.labels", docs[0])["test_label"] ==
"test_label_value"
+
+ def test_can_ingress_hosts_be_templated(self):
+ docs = render_chart(
+ values={
+ "testValues": {
+ "scalar": "aa",
+ "list": ["bb", "cc"],
+ "dict": {
+ "key": "dd",
+ },
+ },
+ "ingress": {
+ "web": {
+ "enabled": True,
+ "hosts": [
+ {"name": "*.{{ .Release.Namespace }}.example.com"},
+ {"name": "{{ .Values.testValues.scalar
}}.example.com"},
+ {"name": "{{ index .Values.testValues.list 1
}}.example.com"},
+ {"name": "{{ .Values.testValues.dict.key
}}.example.com"},
+ ],
+ },
+ },
+ },
+ show_only=["templates/webserver/webserver-ingress.yaml"],
+ namespace="airflow",
+ )
+
+ assert [
+ "*.airflow.example.com",
+ "aa.example.com",
+ "cc.example.com",
+ "dd.example.com",
+ ] == jmespath.search("spec.rules[*].host", docs[0])