Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

[elasticsearch][kibana] Add flexible ingress #994

Merged
merged 4 commits into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions elasticsearch/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "elasticsearch.uname" . -}}
{{- $servicePort := .Values.httpPort -}}
{{- $ingressPath := .Values.ingress.path -}}
{{- $httpPort := .Values.httpPort -}}
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
Expand All @@ -17,22 +16,18 @@ metadata:
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . }}
- host: {{ .host }}
http:
paths:
- path: {{ $ingressPath }}
{{- range .paths }}
- path: {{ .path }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $servicePort }}
servicePort: {{ .servicePort | default $httpPort }}
{{- end }}
{{- end }}
{{- end }}
26 changes: 24 additions & 2 deletions elasticsearch/tests/elasticsearch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,9 +648,19 @@ def test_adding_an_ingress_rule():
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
path: /
hosts:
- elasticsearch.elastic.co
- host: elasticsearch.elastic.co
paths:
- path: /
- host: ''
paths:
- path: /
- path: /mypath
servicePort: 8888
- host: elasticsearch.hello.there
paths:
- path: /
servicePort: 9999
tls:
- secretName: elastic-co-wildcard
hosts:
Expand All @@ -667,6 +677,18 @@ def test_adding_an_ingress_rule():
assert i["rules"][0]["http"]["paths"][0]["path"] == "/"
assert i["rules"][0]["http"]["paths"][0]["backend"]["serviceName"] == uname
assert i["rules"][0]["http"]["paths"][0]["backend"]["servicePort"] == 9200
assert i["rules"][1]["host"] == None
assert i["rules"][1]["http"]["paths"][0]["path"] == "/"
assert i["rules"][1]["http"]["paths"][0]["backend"]["serviceName"] == uname
assert i["rules"][1]["http"]["paths"][0]["backend"]["servicePort"] == 9200
assert i["rules"][1]["http"]["paths"][1]["path"] == "/mypath"
assert i["rules"][1]["http"]["paths"][1]["backend"]["serviceName"] == uname
assert i["rules"][1]["http"]["paths"][1]["backend"]["servicePort"] == 8888
assert i["rules"][2]["host"] == "elasticsearch.hello.there"
assert i["rules"][2]["http"]["paths"][0]["path"] == "/"
assert i["rules"][2]["http"]["paths"][0]["backend"]["serviceName"] == uname
assert i["rules"][2]["http"]["paths"][0]["backend"]["servicePort"] == 9999

kevinsmithwrs marked this conversation as resolved.
Show resolved Hide resolved


def test_changing_the_protocol():
Expand Down
5 changes: 3 additions & 2 deletions elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,10 @@ ingress:
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
path: /
hosts:
- chart-example.local
- host: chart-example.local
paths:
- path: /
tls: []
# - secretName: chart-example-tls
# hosts:
Expand Down
11 changes: 6 additions & 5 deletions kibana/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "kibana.fullname" . -}}
{{- $servicePort := .Values.service.port -}}
{{- $ingressPath := .Values.ingress.path -}}
{{- $httpPort := .Values.httpPort -}}
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
Expand All @@ -18,12 +17,14 @@ spec:
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . }}
- host: {{ .host }}
http:
paths:
- path: {{ $ingressPath }}
{{- range .paths }}
- path: {{ .path }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $servicePort }}
servicePort: {{ .servicePort | default $httpPort }}
{{- end }}
{{- end }}
{{- end }}
30 changes: 26 additions & 4 deletions kibana/tests/kibana_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,19 @@ def test_adding_an_ingress_rule():
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
path: /
hosts:
- kibana.elastic.co
- host: kibana.elastic.co
paths:
- path: /
- path: /testpath
servicePort: 8888
- host: ''
paths:
- path: /
- host: kibana.hello.there
paths:
- path: /mypath
servicePort: 9999
tls:
- secretName: elastic-co-wildcard
hosts:
Expand All @@ -229,6 +239,17 @@ def test_adding_an_ingress_rule():
assert i["rules"][0]["http"]["paths"][0]["path"] == "/"
assert i["rules"][0]["http"]["paths"][0]["backend"]["serviceName"] == name
assert i["rules"][0]["http"]["paths"][0]["backend"]["servicePort"] == 5601
assert i["rules"][0]["http"]["paths"][1]["path"] == "/testpath"
assert i["rules"][0]["http"]["paths"][1]["backend"]["serviceName"] == name
assert i["rules"][0]["http"]["paths"][1]["backend"]["servicePort"] == 8888
assert i["rules"][1]["host"] == None
assert i["rules"][1]["http"]["paths"][0]["path"] == "/"
assert i["rules"][1]["http"]["paths"][0]["backend"]["serviceName"] == name
assert i["rules"][1]["http"]["paths"][0]["backend"]["servicePort"] == 5601
assert i["rules"][2]["host"] == "kibana.hello.there"
assert i["rules"][2]["http"]["paths"][0]["path"] == "/mypath"
assert i["rules"][2]["http"]["paths"][0]["backend"]["serviceName"] == name
assert i["rules"][2]["http"]["paths"][0]["backend"]["servicePort"] == 9999


def test_adding_an_ingress_rule_wildcard():
Expand All @@ -237,9 +258,10 @@ def test_adding_an_ingress_rule_wildcard():
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
path: /
hosts:
- kibana.elastic.co
- host: kibana.elastic.co
paths:
- path: /
tls:
- secretName: elastic-co-wildcard
hosts:
Expand Down
5 changes: 3 additions & 2 deletions kibana/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ ingress:
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
path: /
hosts:
- chart-example.local
- host: chart-example.local
paths:
- path: /
tls: []
# - secretName: chart-example-tls
# hosts:
Expand Down