Skip to content

Commit

Permalink
Use autoscaling/v2 api version if kubernetes version >= 1.23
Browse files Browse the repository at this point in the history
Signed-off-by: Gunnar Scherf <[email protected]>
  • Loading branch information
g10f authored and grieshaber committed Nov 15, 2023
1 parent 84e8240 commit 9f9032d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions charts/keycloak/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta2
{{- $apiVersion := "autoscaling/v2beta2" -}}
{{- if semverCompare ">= v1.23.0-0" .Capabilities.KubeVersion.Version -}}
{{- $apiVersion = "autoscaling/v2" -}}
{{- end }}
apiVersion: {{ $apiVersion }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "keycloak.fullname" . }}
Expand All @@ -15,7 +19,7 @@ spec:
name: {{ include "keycloak.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
metrics:
{{- toYaml .Values.autoscaling.metrics | nindent 4 }}
behavior:
{{- toYaml .Values.autoscaling.behavior | nindent 4 }}
Expand Down
2 changes: 1 addition & 1 deletion charts/keycloak/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ prometheusRule:
# severity: warning

autoscaling:
# If `true`, a autoscaling/v2beta2 HorizontalPodAutoscaler resource is created (requires Kubernetes 1.18 or above)
# If `true`, a autoscaling/v2beta2 or autoscaling/v2 HorizontalPodAutoscaler resource is created (requires Kubernetes 1.18 or 1.23 or above)
# Autoscaling seems to be most reliable when using KUBE_PING service discovery (see README for details)
# This disables the `replicas` field in the StatefulSet
enabled: false
Expand Down

0 comments on commit 9f9032d

Please sign in to comment.