From 7f6454442cb60875952a20c534a2880d70140f24 Mon Sep 17 00:00:00 2001 From: Sara Jarjoura - Sensible <97973481+sarasensible@users.noreply.github.com> Date: Wed, 12 Apr 2023 14:54:26 -0400 Subject: [PATCH] fix(hpa) Add autoscaling v2 support (#152) * feat(env-vars) Add extra env vars and envFrom * Switch to main * fix(hpa) Add autoscaling v2 support --- chart/templates/hpa.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/chart/templates/hpa.yaml b/chart/templates/hpa.yaml index 3409ae2d..42e62927 100644 --- a/chart/templates/hpa.yaml +++ b/chart/templates/hpa.yaml @@ -1,6 +1,12 @@ {{- if not .Values.useStatefulset.enabled -}} {{- if .Values.autoscaling.enabled }} +{{- if .Capabilities.APIVersions.Has "autoscaling/v2" }} +apiVersion: autoscaling/v2 +{{- else if .Capabilities.APIVersions.Has "autoscaling/v2beta2" }} +apiVersion: autoscaling/v2beta2 +{{- else }} apiVersion: autoscaling/v2beta1 +{{- end }} kind: HorizontalPodAutoscaler metadata: name: {{ include "kube-httpcache.fullname" . }} @@ -18,13 +24,25 @@ spec: - type: Resource resource: name: cpu + {{- if or (.Capabilities.APIVersions.Has "autoscaling/v2") (.Capabilities.APIVersions.Has "autoscaling/v2beta2") }} + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- else }} targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} {{- end }} {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - type: Resource resource: name: memory + {{- if or (.Capabilities.APIVersions.Has "autoscaling/v2") (.Capabilities.APIVersions.Has "autoscaling/v2beta2") }} + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- else }} targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} {{- end }} {{- end }} {{- end }}