From df2b2e01deb1f7896e634c53ef8082c87978e472 Mon Sep 17 00:00:00 2001 From: Narekmat <47845266+Narekmat@users.noreply.github.com> Date: Wed, 14 Sep 2022 13:16:28 +0400 Subject: [PATCH] fix kubeval (#2505) * fix kubeval * fix kubeval * fix kubeval * fix issue with hpa * fix version to 1.24.0 * fix 1.25 --- charts/kafka-ui/templates/hpa.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/charts/kafka-ui/templates/hpa.yaml b/charts/kafka-ui/templates/hpa.yaml index 1509ef3f01..1cc131c9e9 100644 --- a/charts/kafka-ui/templates/hpa.yaml +++ b/charts/kafka-ui/templates/hpa.yaml @@ -1,5 +1,11 @@ {{- if .Values.autoscaling.enabled }} +{{- $kubeCapabilityVersion := semver .Capabilities.KubeVersion.Version -}} +{{- $isHigher1p25 := ge (semver "1.25" | $kubeCapabilityVersion.Compare) 0 -}} +{{- if and ($.Capabilities.APIVersions.Has "autoscaling/v2") $isHigher1p25 -}} +apiVersion: autoscaling/v2 +{{- else }} apiVersion: autoscaling/v2beta1 +{{- end }} kind: HorizontalPodAutoscaler metadata: name: {{ include "kafka-ui.fullname" . }} @@ -17,12 +23,24 @@ spec: - type: Resource resource: name: cpu + {{- if $isHigher1p25 }} + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- else }} targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} {{- end }} {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - type: Resource resource: name: memory + {{- if $isHigher1p25 }} + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- else }} targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} {{- end }} + {{- end }} {{- end }}