Skip to content

Commit b5f3c23

Browse files
committed
Adding HPA capabilities check
1 parent 40ea5c5 commit b5f3c23

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

helm/oauth2-proxy/templates/_capabilities.tpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,14 @@ Return the appropriate apiVersion for ingress object.
2121
{{- print "networking.k8s.io/v1" -}}
2222
{{- end -}}
2323
{{- end -}}
24+
25+
{{/*
26+
Return the appropriate apiVersion for HorizontalPodAutoscaler object.
27+
*/}}
28+
{{- define "capabilities.horizontalPodAutoscaler.apiVersion" -}}
29+
{{- if semverCompare "<1.23-0" ( .Values.kubeVersion | default .Capabilities.KubeVersion.Version ) -}}
30+
{{- print "autoscaling/v2beta2" -}}
31+
{{- else -}}
32+
{{- print "autoscaling/v2" -}}
33+
{{- end -}}
34+
{{- end -}}

helm/oauth2-proxy/templates/hpa.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- if .Values.autoscaling.enabled }}
2-
apiVersion: autoscaling/v2
2+
apiVersion: {{ include "capabilities.horizontalPodAutoscaler.apiVersion" . }}
33
kind: HorizontalPodAutoscaler
44
metadata:
55
labels:

0 commit comments

Comments
 (0)