Skip to content

Commit d838b7f

Browse files
authored
Merge pull request #45 from j0nm1/improve-ingress
Allow specification of Ingress pathType
2 parents 2607589 + da50abb commit d838b7f

File tree

6 files changed

+51
-5
lines changed

6 files changed

+51
-5
lines changed

charts/ltb-passwd/templates/_helpers.tpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,14 @@ Generate chart secret name
4949
{{- define "ltb-passwd.secretName" -}}
5050
{{ default (include "ltb-passwd.fullname" .) .Values.existingSecret }}
5151
{{- end -}}
52+
53+
{{/*
54+
Return the appropriate apiVersion for ingress.
55+
*/}}
56+
{{- define "ingress.apiVersion" -}}
57+
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1" -}}
58+
{{- print "networking.k8s.io/v1" -}}
59+
{{- else -}}
60+
{{- print "extensions/v1beta1" -}}
61+
{{- end -}}
62+
{{- end -}}

charts/ltb-passwd/templates/ingress.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{{- if .Values.ingress.enabled -}}
22
{{- $fullName := include "ltb-passwd.fullname" . -}}
33
{{- $ingressPath := .Values.ingress.path -}}
4-
apiVersion: extensions/v1beta1
4+
{{- $ingressPathType := .Values.ingress.pathType -}}
5+
apiVersion: {{ include "ingress.apiVersion" . }}
56
kind: Ingress
67
metadata:
78
name: {{ $fullName }}
@@ -31,8 +32,18 @@ spec:
3132
http:
3233
paths:
3334
- path: {{ $ingressPath }}
35+
{{- if eq (include "ingress.apiVersion" $) "networking.k8s.io/v1" }}
36+
pathType: {{ $ingressPathType }}
37+
{{- end }}
3438
backend:
39+
{{- if eq (include "ingress.apiVersion" $) "networking.k8s.io/v1" }}
40+
service:
41+
name: {{ $fullName }}
42+
port:
43+
name: http
44+
{{- else }}
3545
serviceName: {{ $fullName }}
3646
servicePort: http
47+
{{- end }}
3748
{{- end }}
3849
{{- end }}

charts/phpldapadmin/templates/_helpers.tpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,14 @@ Create chart name and version as used by the chart label.
3030
{{- define "phpldapadmin.chart" -}}
3131
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
3232
{{- end -}}
33+
34+
{{/*
35+
Return the appropriate apiVersion for ingress.
36+
*/}}
37+
{{- define "ingress.apiVersion" -}}
38+
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1" -}}
39+
{{- print "networking.k8s.io/v1" -}}
40+
{{- else -}}
41+
{{- print "extensions/v1beta1" -}}
42+
{{- end -}}
43+
{{- end -}}

charts/phpldapadmin/templates/ingress.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{{- if .Values.ingress.enabled -}}
22
{{- $fullName := include "phpldapadmin.fullname" . -}}
33
{{- $ingressPath := .Values.ingress.path -}}
4-
apiVersion: extensions/v1beta1
4+
{{- $ingressPathType := .Values.ingress.pathType -}}
5+
apiVersion: {{ include "ingress.apiVersion" . }}
56
kind: Ingress
67
metadata:
78
name: {{ $fullName }}
@@ -31,8 +32,18 @@ spec:
3132
http:
3233
paths:
3334
- path: {{ $ingressPath }}
35+
{{- if eq (include "ingress.apiVersion" $) "networking.k8s.io/v1" }}
36+
pathType: {{ $ingressPathType }}
37+
{{- end }}
3438
backend:
39+
{{- if eq (include "ingress.apiVersion" $) "networking.k8s.io/v1" }}
40+
service:
41+
name: {{ $fullName }}
42+
port:
43+
name: http
44+
{{- else }}
3545
serviceName: {{ $fullName }}
3646
servicePort: http
47+
{{- end }}
3748
{{- end }}
3849
{{- end }}

templates/_helpers.tpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ Expand the name of the chart.
99
Return the appropriate apiVersion for statefulset.
1010
*/}}
1111
{{- define "statefulset.apiVersion" -}}
12-
{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}}
13-
{{- print "apps/v1beta1" -}}
14-
{{- else -}}
12+
{{- if .Capabilities.APIVersions.Has "apps/v1" -}}
1513
{{- print "apps/v1" -}}
14+
{{- else -}}
15+
{{- print "apps/v1beta1" -}}
1616
{{- end -}}
1717
{{- end -}}
1818
{{/*

values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ ltb-passwd:
205205
enabled: true
206206
annotations: {}
207207
path: /
208+
pathType: Prefix
208209
## Ingress Host
209210
hosts:
210211
- "ssl-ldap2.example"
@@ -221,6 +222,7 @@ phpldapadmin:
221222
enabled: true
222223
annotations: {}
223224
path: /
225+
pathType: Prefix
224226
## Ingress Host
225227
hosts:
226228
- phpldapadmin.example

0 commit comments

Comments
 (0)