From a2aed2723c8b6782f62b5655ed35402cded16c7b Mon Sep 17 00:00:00 2001
From: David Bauer <david.bauer@open-xchange.com>
Date: Fri, 9 Dec 2022 13:57:00 +0100
Subject: [PATCH] Change: Update helm chart to autoscaling/v2

---
 helm/core-ui-middleware/templates/deployment.yaml |  2 ++
 helm/core-ui-middleware/templates/hpa.yaml        | 10 +++++++---
 helm/core-ui-middleware/values.yaml               |  2 +-
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/helm/core-ui-middleware/templates/deployment.yaml b/helm/core-ui-middleware/templates/deployment.yaml
index 66e7484..63e0159 100644
--- a/helm/core-ui-middleware/templates/deployment.yaml
+++ b/helm/core-ui-middleware/templates/deployment.yaml
@@ -5,7 +5,9 @@ metadata:
   labels:
     {{- include "ox-common.labels.standard" . | nindent 4 }}
 spec:
+  {{- if not .Values.autoscaling.enabled }}
   replicas: {{ .Values.replicaCount }}
+  {{- end }}
   selector:
     matchLabels:
       {{- include "ox-common.labels.matchLabels" . | nindent 6 }}
diff --git a/helm/core-ui-middleware/templates/hpa.yaml b/helm/core-ui-middleware/templates/hpa.yaml
index e639743..10e2940 100644
--- a/helm/core-ui-middleware/templates/hpa.yaml
+++ b/helm/core-ui-middleware/templates/hpa.yaml
@@ -1,5 +1,5 @@
 {{- if .Values.autoscaling.enabled }}
-apiVersion: autoscaling/v2beta1
+apiVersion: autoscaling/v2
 kind: HorizontalPodAutoscaler
 metadata:
   name: {{ include "core-ui-middleware.fullname" . }}
@@ -17,12 +17,16 @@ spec:
     - type: Resource
       resource:
         name: cpu
-        targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
+        target:
+          type: Utilization
+          averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
     {{- end }}
     {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
     - type: Resource
       resource:
         name: memory
-        targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
+        target:
+          type: Utilization
+          averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
     {{- end }}
 {{- end }}
diff --git a/helm/core-ui-middleware/values.yaml b/helm/core-ui-middleware/values.yaml
index 4d35504..6b421a2 100644
--- a/helm/core-ui-middleware/values.yaml
+++ b/helm/core-ui-middleware/values.yaml
@@ -78,7 +78,7 @@ autoscaling:
   minReplicas: 1
   maxReplicas: 100
   targetCPUUtilizationPercentage: 80
-  # targetMemoryUtilizationPercentage: 80
+  targetMemoryUtilizationPercentage: 80
 
 nodeSelector: {}
 
-- 
GitLab