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 }} 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: