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

[all] Add support to ingress networking.k8s.io/v1 & ingressClassName #1409

Merged
merged 14 commits into from
Oct 14, 2021
Merged
27 changes: 15 additions & 12 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 @@ -12,23 +13,25 @@ metadata:
{{- range $key, $value := .Values.labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- with .Values.ingress.annotations }}
annotations:
{{ 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 }}
4 changes: 3 additions & 1 deletion apm-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ autoscaling:
averageCpuUtilization: 50

ingress:
enabled: false
enabled: true
className: ""
pathtype: ImplementationSpecific
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
Expand Down
72 changes: 41 additions & 31 deletions elasticsearch/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,54 +1,64 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "elasticsearch.uname" . -}}
{{- $httpPort := .Values.httpPort -}}
{{- $pathtype := .Values.ingress.pathtype -}}
{{- $ingressPath := .Values.ingress.path -}}
{{- if semverCompare "<1.19-0" .Capabilities.KubeVersion.Version }}
apiVersion: networking.k8s.io/v1beta1
{{- else }}
apiVersion: networking.k8s.io/v1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
app: {{ .Chart.Name }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.ingress.annotations }}
annotations:
{{ 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 }}
20 changes: 10 additions & 10 deletions elasticsearch/tests/elasticsearch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,19 +644,19 @@ 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 +682,8 @@ 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
8 changes: 6 additions & 2 deletions elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ esMajorVersion: ""

# Allows you to add any config files in /usr/share/elasticsearch/config/
# such as elasticsearch.yml and log4j2.properties
esConfig: {}
esConfig: {}
# elasticsearch.yml: |
# xpack.security.enabled: false
# key:
# nestedkey: value
# log4j2.properties: |
# key = value


# Extra environment variables to append to this nodeGroup
# This will be appended to the current 'env:' key. You can use any of the kubernetes env
# syntax here
Expand Down Expand Up @@ -240,9 +242,11 @@ tolerations: []
# Only enable this if you have security enabled on your cluster
ingress:
enabled: false
annotations: {}
className: ""
#annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
pathtype: ImplementationSpecific
hosts:
- host: chart-example.local
paths:
Expand Down
58 changes: 32 additions & 26 deletions kibana/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{{- 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 }}
labels: {{ include "kibana.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{ 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 +21,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 }}
10 changes: 6 additions & 4 deletions kibana/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
elasticsearchHosts: "http://elasticsearch-master:9200"
elasticsearchHosts: "http://my-es-helm:9200"

replicas: 1

Expand Down Expand Up @@ -127,15 +127,17 @@ service:
httpPortName: http

ingress:
enabled: false
enabled: true
className: ""
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
45 changes: 30 additions & 15 deletions logstash/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "logstash.fullname" . -}}
apiVersion: networking.k8s.io/v1beta1
{{- $httpPort := .Values.httpPort -}}
{{- $ingressPath := .Values.ingress.path -}}
{{- $pathtype := .Values.ingress.pathtype -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
Expand All @@ -9,25 +12,37 @@ metadata:
chart: "{{ .Chart.Name }}"
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
{{- with .Values.ingress.annotations }}
annotations:
{{ 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 }}
{{- end }}
{{- else }}
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- end }}
{{- end }}
{{end}}
rules:
{{- range $.Values.ingress.hosts }}
- host: {{ .host }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ .servicePort }}
{{- end }}
- host: {{ .host }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: {{ $pathtype }}
backend:
service:
name: {{ $fullName }}
port:
number: {{ $httpPort }}
{{- end }}
{{- end }}
{{- end }}
Loading