From fd83164ad5811070d20210c49a6a9383c098662a Mon Sep 17 00:00:00 2001 From: Wouter de Geus Date: Tue, 5 Jan 2021 13:11:48 +0100 Subject: [PATCH 1/2] [elasticsearch] Make ingress host optional Signed-off-by: Wouter de Geus --- elasticsearch/templates/ingress.yaml | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/elasticsearch/templates/ingress.yaml b/elasticsearch/templates/ingress.yaml index bcb2befa6..0012c2498 100644 --- a/elasticsearch/templates/ingress.yaml +++ b/elasticsearch/templates/ingress.yaml @@ -30,8 +30,9 @@ spec: {{- end }} {{- end }} rules: - {{- range .Values.ingress.hosts }} - {{- if $ingressPath }} + {{- if .Values.ingress.hosts }} + {{- range .Values.ingress.hosts }} + {{- if $ingressPath }} - host: {{ . }} http: paths: @@ -39,7 +40,7 @@ spec: backend: serviceName: {{ $fullName }} servicePort: {{ $httpPort }} - {{- else }} + {{- else }} - host: {{ .host }} http: paths: @@ -49,6 +50,25 @@ spec: serviceName: {{ $fullName }} servicePort: {{ .servicePort | default $httpPort }} {{- end }} + {{- end }} + {{- end }} + {{- else }} + {{- if $ingressPath }} + - http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $httpPort }} + {{- else }} + - http: + paths: + {{- range .paths }} + - path: {{ .path }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ .servicePort | default $httpPort }} + {{- end }} {{- end }} {{- end }} {{- end }} From 4d6d56e1e02f8ba055ae4f6fe9260dcb9f8e0dda Mon Sep 17 00:00:00 2001 From: Wouter de Geus Date: Tue, 5 Jan 2021 13:21:51 +0100 Subject: [PATCH 2/2] [elasticsearch] Add test case for empty hosts ingress Signed-off-by: Wouter de Geus --- elasticsearch/tests/elasticsearch_test.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/elasticsearch/tests/elasticsearch_test.py b/elasticsearch/tests/elasticsearch_test.py index 9340eba9e..4b2bd11bf 100755 --- a/elasticsearch/tests/elasticsearch_test.py +++ b/elasticsearch/tests/elasticsearch_test.py @@ -690,6 +690,22 @@ def test_adding_an_ingress_rule(): assert i["rules"][2]["http"]["paths"][0]["backend"]["servicePort"] == 9999 +def test_adding_ingress_without_hosts(): + config = """ +ingress: + enabled: true + annotations: + kubernetes.io/ingress.class: nginx + path: / + hosts: +""" + + r = helm_template(config) + assert uname in r["ingress"] + i = r["ingress"][uname]["spec"] + assert i["rules"][0]["http"]["paths"][0]["path"] == "/" + + def test_adding_a_deprecated_ingress_rule(): config = """ ingress: