Skip to content

Commit daee488

Browse files
update to modern ingress for helm chart
1 parent 3bfaba3 commit daee488

File tree

2 files changed

+38
-37
lines changed

2 files changed

+38
-37
lines changed
Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,50 @@
11
{{- if .Values.ingress.enabled -}}
22
{{- $serviceName := include "docker-auth.fullname" . -}}
33
{{- $servicePort := .Values.service.port -}}
4-
{{- $path := .Values.ingress.path -}}
5-
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" -}}
64
apiVersion: networking.k8s.io/v1
7-
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress" -}}
8-
apiVersion: networking.k8s.io/v1beta1
9-
{{- else -}}
10-
apiVersion: extensions/v1beta1
11-
{{- end }}
125
kind: Ingress
136
metadata:
14-
name: {{ template "docker-auth.fullname" . }}
7+
name: {{ include "docker-auth.fullname" . }}
8+
namespace: {{ .Release.Namespace }}
159
labels:
16-
app: {{ template "docker-auth.name" . }}
17-
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
18-
release: {{ .Release.Name }}
19-
heritage: {{ .Release.Service }}
20-
{{- if .Values.ingress.labels }}
21-
{{ toYaml .Values.ingress.labels | indent 4 }}
22-
{{- end }}
10+
app.kubernetes.io/name: {{ include "docker-auth.name" . }}
11+
helm.sh/chart: {{ include "docker-auth.chart" . }}
12+
app.kubernetes.io/instance: {{ .Release.Name }}
13+
app.kubernetes.io/managed-by: {{ .Release.Service }}
14+
{{- with .Values.ingress.labels }}
15+
{{- toYaml . | nindent 4 }}
16+
{{- end }}
17+
{{- with .Values.ingress.annotations }}
2318
annotations:
24-
{{- range $key, $value := .Values.ingress.annotations }}
25-
{{ $key }}: {{ $value | quote }}
26-
{{- end }}
19+
{{- toYaml . | nindent 4 }}
20+
{{- end }}
2721
spec:
22+
{{- if .Values.ingress.className }}
23+
ingressClassName: {{ .Values.ingress.className }}
24+
{{- end }}
25+
{{- if .Values.ingress.tls }}
26+
tls:
27+
{{- range .Values.ingress.tls }}
28+
- hosts:
29+
{{- range .hosts }}
30+
- {{ . | quote }}
31+
{{- end }}
32+
secretName: {{ .secretName }}
33+
{{- end }}
34+
{{- end }}
2835
rules:
29-
{{- range $host := .Values.ingress.hosts }}
30-
- host: {{ $host }}
36+
{{- range .Values.ingress.hosts }}
37+
- host: {{ .host | quote }}
3138
http:
3239
paths:
33-
- path: {{ $path }}
34-
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
35-
pathType: Prefix
36-
{{- end }}
40+
{{- range .paths }}
41+
- path: {{ .path }}
42+
pathType: {{ .pathType | default "Prefix" }}
3743
backend:
38-
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
3944
service:
4045
name: {{ $serviceName }}
4146
port:
4247
number: {{ $servicePort }}
43-
{{- else }}
44-
serviceName: {{ $serviceName }}
45-
servicePort: {{ $servicePort }}
46-
{{- end }}
47-
{{- end -}}
48-
{{- if .Values.ingress.tls }}
49-
tls:
50-
{{ toYaml .Values.ingress.tls | indent 4 }}
51-
{{- end -}}
52-
{{- end -}}
48+
{{- end }}
49+
{{- end }}
50+
{{- end }}

chart/docker-auth/values.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,17 @@ service:
4848

4949
ingress:
5050
enabled: true
51+
className: ""
5152
annotations: {}
5253
# kubernetes.io/ingress.class: nginx
5354
# kubernetes.io/tls-acme: "true"
55+
# nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
56+
labels: {}
5457
hosts:
5558
- host: docker-auth.test.com
5659
paths:
57-
- /
58-
60+
- path: /
61+
pathType: Prefix
5962
tls: []
6063
# - secretName: chart-example-tls
6164
# hosts:

0 commit comments

Comments
 (0)