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

Commit

Permalink
[all] Add support to ingress networking.k8s.io/v1 & ingressClassName (#…
Browse files Browse the repository at this point in the history
…1409)

* Adding support to Ingress networking.k8s.io/v1

* Adjusting ES service name

* Removing ingress typo & adjusting python test

* Adjusting python tests to use the new ingress version

* fixing conflict

* Adding support to kubernetes ingress v1 & ClassName

* Adding reformatted files

* fixing conflict

* Adding ClassName & Pathtype on ingress settings

* Performing syntax adjustments and removing comments
  • Loading branch information
framsouza committed Oct 14, 2021
1 parent b5e5609 commit 57aa59a
Show file tree
Hide file tree
Showing 11 changed files with 202 additions and 111 deletions.
23 changes: 15 additions & 8 deletions apm-server/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "apm.fullname" . -}}
{{- $servicePort := .Values.service.port -}}
{{- $pathtype := .Values.ingress.pathtype -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: networking.k8s.io/v1beta1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ template "apm.fullname" . }}
Expand All @@ -17,18 +18,24 @@ metadata:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.className }}
ingressClassName: {{ .Values.ingress.className | quote }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $servicePort }}
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}
pathType: {{ $pathtype }}
backend:
service:
name: {{ $fullName }}
port:
number: {{ $servicePort }}
{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions apm-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ autoscaling:

ingress:
enabled: false
className: "nginx"
pathtype: ImplementationSpecific
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
Expand Down
66 changes: 38 additions & 28 deletions elasticsearch/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "elasticsearch.uname" . -}}
{{- $httpPort := .Values.httpPort -}}
{{- $pathtype := .Values.ingress.pathtype -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: networking.k8s.io/v1beta1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
Expand All @@ -15,40 +16,49 @@ metadata:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.className }}
ingressClassName: {{ .Values.ingress.className | quote }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- if .ingressPath }}
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . }}
{{- end }}
secretName: {{ .secretName }}
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . }}
{{- end }}
{{- else }}
secretName: {{ .secretName }}
{{- end }}
{{- else }}
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- end }}
{{- end }}
{{- end}}
rules:
{{- range .Values.ingress.hosts }}
{{- if $ingressPath }}
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $httpPort }}
{{- else }}
- host: {{ .host }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ .servicePort | default $httpPort }}
{{- end }}
{{- end }}
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}
pathType: {{ $pathtype }}
backend:
service:
name: {{ $fullName }}
port:
number: {{ $httpPort }}
{{- else }}
- host: {{ .host }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: {{ $pathtype }}
backend:
service:
name: {{ $fullName }}
port:
number: {{ .servicePort | default $httpPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
35 changes: 25 additions & 10 deletions elasticsearch/tests/elasticsearch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,19 +644,31 @@ def test_adding_an_ingress_rule():

assert i["rules"][0]["host"] == "elasticsearch.elastic.co"
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"][0]["http"]["paths"][0]["backend"]["service"]["name"] == uname
assert (
i["rules"][0]["http"]["paths"][0]["backend"]["service"]["port"]["number"]
== 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"][0]["backend"]["service"]["name"] == uname
assert (
i["rules"][1]["http"]["paths"][0]["backend"]["service"]["port"]["number"]
== 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"][1]["http"]["paths"][1]["backend"]["service"]["name"] == uname
assert (
i["rules"][1]["http"]["paths"][1]["backend"]["service"]["port"]["number"]
== 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
assert i["rules"][2]["http"]["paths"][0]["backend"]["service"]["name"] == uname
assert (
i["rules"][2]["http"]["paths"][0]["backend"]["service"]["port"]["number"]
== 9999
)


def test_adding_a_deprecated_ingress_rule():
Expand All @@ -682,8 +694,11 @@ def test_adding_a_deprecated_ingress_rule():

assert i["rules"][0]["host"] == "elasticsearch.elastic.co"
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"][0]["http"]["paths"][0]["backend"]["service"]["name"] == uname
assert (
i["rules"][0]["http"]["paths"][0]["backend"]["service"]["port"]["number"]
== 9200
)


def test_changing_the_protocol():
Expand Down
2 changes: 2 additions & 0 deletions elasticsearch/values.yaml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ tolerations: []
ingress:
enabled: false
annotations: {}
className: "nginx"
pathtype: ImplementationSpecific
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
Expand Down
54 changes: 32 additions & 22 deletions kibana/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "kibana.fullname" . -}}
{{- $httpPort := .Values.httpPort -}}
{{- $pathtype := .Values.ingress.pathtype -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: networking.k8s.io/v1beta1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
Expand All @@ -12,6 +13,9 @@ metadata:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.className }}
ingressClassName: {{ .Values.ingress.className | quote }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- if .ingressPath }}
Expand All @@ -21,31 +25,37 @@ spec:
- {{ . }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- else }}
{{- end }}
{{- else }}
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
{{- if $ingressPath }}
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $httpPort }}
{{- else }}
- host: {{ .host }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ .servicePort | default $httpPort }}
{{- end }}
{{- end }}
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}
pathType: {{ $pathtype }}
backend:
service:
name: {{ $fullName }}
port:
number: {{ $httpPort }}
{{- else }}
- host: {{ .host }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: {{ $pathtype }}
backend:
service:
name: {{ $fullName }}
port:
number: {{ .servicePort | default $httpPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
49 changes: 35 additions & 14 deletions kibana/tests/kibana_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,31 @@ def test_adding_an_ingress_rule():

assert i["rules"][0]["host"] == "kibana.elastic.co"
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"][0]["backend"]["service"]["name"] == name
assert (
i["rules"][0]["http"]["paths"][0]["backend"]["service"]["port"]["number"]
== 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"][0]["http"]["paths"][1]["backend"]["service"]["name"] == name
assert (
i["rules"][0]["http"]["paths"][1]["backend"]["service"]["port"]["number"]
== 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"][1]["http"]["paths"][0]["backend"]["service"]["name"] == name
assert (
i["rules"][1]["http"]["paths"][0]["backend"]["service"]["port"]["number"]
== 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
assert i["rules"][2]["http"]["paths"][0]["backend"]["service"]["name"] == name
assert (
i["rules"][2]["http"]["paths"][0]["backend"]["service"]["port"]["number"]
== 9999
)


def test_adding_a_deprecated_ingress_rule():
Expand All @@ -298,8 +310,11 @@ def test_adding_a_deprecated_ingress_rule():

assert i["rules"][0]["host"] == "kibana.elastic.co"
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"][0]["backend"]["service"]["name"] == name
assert (
i["rules"][0]["http"]["paths"][0]["backend"]["service"]["port"]["number"]
== 5601
)


def test_adding_an_ingress_rule_wildcard():
Expand All @@ -326,8 +341,11 @@ def test_adding_an_ingress_rule_wildcard():

assert i["rules"][0]["host"] == "kibana.elastic.co"
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"][0]["backend"]["service"]["name"] == name
assert (
i["rules"][0]["http"]["paths"][0]["backend"]["service"]["port"]["number"]
== 5601
)


def test_adding_a_deprecated_ingress_rule_wildcard():
Expand All @@ -353,8 +371,11 @@ def test_adding_a_deprecated_ingress_rule_wildcard():

assert i["rules"][0]["host"] == "kibana.elastic.co"
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"][0]["backend"]["service"]["name"] == name
assert (
i["rules"][0]["http"]["paths"][0]["backend"]["service"]["port"]["number"]
== 5601
)


def test_override_the_default_update_strategy():
Expand Down
6 changes: 4 additions & 2 deletions kibana/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,16 @@ service:

ingress:
enabled: false
className: "nginx"
pathtype: ImplementationSpecific
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
- host: kibana-example.local
paths:
- path: /
tls: []
#tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
Expand Down
Loading

0 comments on commit 57aa59a

Please sign in to comment.