Skip to content

Commit

Permalink
Change Ingress Api Version Logic
Browse files Browse the repository at this point in the history
Signed-off-by: sewieland <[email protected]>
  • Loading branch information
sewieland authored and Mirco Hacker committed Dec 10, 2021
1 parent 3c09f5c commit dafb188
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion charts/keycloak/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: keycloak
version: 16.0.0
version: 16.0.1
appVersion: 15.0.2
description: Open Source Identity and Access Management For Modern Applications and Services
keywords:
Expand Down
11 changes: 0 additions & 11 deletions charts/keycloak/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,3 @@ Create the service DNS name.
{{- define "keycloak.serviceDnsName" -}}
{{ include "keycloak.fullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}
{{- end }}

{{/*
Return the appropriate apiVersion for ingress.
*/}}
{{- define "keycloak.ingressAPIVersion" -}}
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" -}}
{{- print "networking.k8s.io/v1" -}}
{{- else -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- end -}}
{{- end -}}
18 changes: 14 additions & 4 deletions charts/keycloak/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{{- $ingress := .Values.ingress -}}
{{- if $ingress.enabled -}}
apiVersion: {{ include "keycloak.ingressAPIVersion" . }}
{{- $apiV1 := false -}}
{{- $apiVersion := "extensions/v1beta1" -}}
{{- if and (.Capabilities.APIVersions.Has "networking.k8s.io/v1") (semverCompare ">= v1.19.0-0" .Capabilities.KubeVersion.Version) -}}
{{- $apiVersion = "networking.k8s.io/v1" -}}
{{- $apiV1 = true -}}
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}}
{{- $apiVersion = "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- $apiVersion = "extensions/v1beta1" -}}
{{- end }}
apiVersion: {{ $apiVersion }}
kind: Ingress
metadata:
name: {{ include "keycloak.fullname" . }}
Expand Down Expand Up @@ -38,7 +48,7 @@ spec:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
{{- if $apiV1 }}
pathType: {{ .pathType }}
backend:
service:
Expand All @@ -54,7 +64,7 @@ spec:
{{- end }}
{{- if $ingress.console.enabled }}
---
apiVersion: {{ include "keycloak.ingressAPIVersion" . }}
apiVersion: {{ $apiVersion }}
kind: Ingress
metadata:
name: {{ include "keycloak.fullname" . }}-console
Expand Down Expand Up @@ -92,7 +102,7 @@ spec:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
{{- if $apiV1 }}
pathType: {{ .pathType }}
backend:
service:
Expand Down

0 comments on commit dafb188

Please sign in to comment.