Skip to content

Commit dafb188

Browse files
sewielandMirco Hacker
authored andcommitted
Change Ingress Api Version Logic
Signed-off-by: sewieland <[email protected]>
1 parent 3c09f5c commit dafb188

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

charts/keycloak/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: keycloak
3-
version: 16.0.0
3+
version: 16.0.1
44
appVersion: 15.0.2
55
description: Open Source Identity and Access Management For Modern Applications and Services
66
keywords:

charts/keycloak/templates/_helpers.tpl

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,3 @@ Create the service DNS name.
7474
{{- define "keycloak.serviceDnsName" -}}
7575
{{ include "keycloak.fullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}
7676
{{- end }}
77-
78-
{{/*
79-
Return the appropriate apiVersion for ingress.
80-
*/}}
81-
{{- define "keycloak.ingressAPIVersion" -}}
82-
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" -}}
83-
{{- print "networking.k8s.io/v1" -}}
84-
{{- else -}}
85-
{{- print "networking.k8s.io/v1beta1" -}}
86-
{{- end -}}
87-
{{- end -}}

charts/keycloak/templates/ingress.yaml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
{{- $ingress := .Values.ingress -}}
22
{{- if $ingress.enabled -}}
3-
apiVersion: {{ include "keycloak.ingressAPIVersion" . }}
3+
{{- $apiV1 := false -}}
4+
{{- $apiVersion := "extensions/v1beta1" -}}
5+
{{- if and (.Capabilities.APIVersions.Has "networking.k8s.io/v1") (semverCompare ">= v1.19.0-0" .Capabilities.KubeVersion.Version) -}}
6+
{{- $apiVersion = "networking.k8s.io/v1" -}}
7+
{{- $apiV1 = true -}}
8+
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}}
9+
{{- $apiVersion = "networking.k8s.io/v1beta1" -}}
10+
{{- else -}}
11+
{{- $apiVersion = "extensions/v1beta1" -}}
12+
{{- end }}
13+
apiVersion: {{ $apiVersion }}
414
kind: Ingress
515
metadata:
616
name: {{ include "keycloak.fullname" . }}
@@ -38,7 +48,7 @@ spec:
3848
paths:
3949
{{- range .paths }}
4050
- path: {{ .path }}
41-
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
51+
{{- if $apiV1 }}
4252
pathType: {{ .pathType }}
4353
backend:
4454
service:
@@ -54,7 +64,7 @@ spec:
5464
{{- end }}
5565
{{- if $ingress.console.enabled }}
5666
---
57-
apiVersion: {{ include "keycloak.ingressAPIVersion" . }}
67+
apiVersion: {{ $apiVersion }}
5868
kind: Ingress
5969
metadata:
6070
name: {{ include "keycloak.fullname" . }}-console
@@ -92,7 +102,7 @@ spec:
92102
paths:
93103
{{- range .paths }}
94104
- path: {{ .path }}
95-
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
105+
{{- if $apiV1 }}
96106
pathType: {{ .pathType }}
97107
backend:
98108
service:

0 commit comments

Comments
 (0)