From 2dd1260688184f34e2df4869caa82b8774042861 Mon Sep 17 00:00:00 2001 From: Marco Ebert Date: Mon, 24 Apr 2023 18:02:53 +0200 Subject: [PATCH] HPA: Align to upstream. --- CHANGELOG.md | 1 + .../templates/controller-hpa.yaml | 11 +++--- .../templates/default-backend-hpa.yaml | 35 +++++++++++-------- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73aee985..a1737684 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project's packages adheres to [Semantic Versioning](http://semver.org/s - Helpers: Align labels to upstream. ([#450](https://github.com/giantswarm/nginx-ingress-controller-app/pull/450)) - Values: Align CPU & memory requests to actual needs. ([#453](https://github.com/giantswarm/nginx-ingress-controller-app/pull/453)) - Values: Deprecate `configmap`, use `controller.config` instead. ([#463](https://github.com/giantswarm/nginx-ingress-controller-app/pull/463)) +- HPA: Align to upstream. ([#465](https://github.com/giantswarm/nginx-ingress-controller-app/pull/465)) ### Removed diff --git a/helm/nginx-ingress-controller-app/templates/controller-hpa.yaml b/helm/nginx-ingress-controller-app/templates/controller-hpa.yaml index a9577e21..96a91f53 100644 --- a/helm/nginx-ingress-controller-app/templates/controller-hpa.yaml +++ b/helm/nginx-ingress-controller-app/templates/controller-hpa.yaml @@ -2,9 +2,8 @@ apiVersion: {{ ternary "autoscaling/v2" "autoscaling/v2beta2" (.Capabilities.APIVersions.Has "autoscaling/v2") }} kind: HorizontalPodAutoscaler metadata: - annotations: {{- with .Values.controller.autoscaling.annotations }} - {{- toYaml . | trimSuffix "\n" | nindent 4 }} + annotations: {{ toYaml . | nindent 4 }} {{- end }} labels: {{- include "ingress-nginx.labels" . | nindent 4 }} @@ -22,18 +21,18 @@ spec: minReplicas: {{ .Values.controller.autoscaling.minReplicas }} maxReplicas: {{ .Values.controller.autoscaling.maxReplicas }} metrics: - {{- with .Values.controller.autoscaling.targetMemoryUtilizationPercentage }} + {{- with .Values.controller.autoscaling.targetCPUUtilizationPercentage }} - type: Resource resource: - name: memory + name: cpu target: type: Utilization averageUtilization: {{ . }} {{- end }} - {{- with .Values.controller.autoscaling.targetCPUUtilizationPercentage }} + {{- with .Values.controller.autoscaling.targetMemoryUtilizationPercentage }} - type: Resource resource: - name: cpu + name: memory target: type: Utilization averageUtilization: {{ . }} diff --git a/helm/nginx-ingress-controller-app/templates/default-backend-hpa.yaml b/helm/nginx-ingress-controller-app/templates/default-backend-hpa.yaml index 8b511679..faaf4fa7 100644 --- a/helm/nginx-ingress-controller-app/templates/default-backend-hpa.yaml +++ b/helm/nginx-ingress-controller-app/templates/default-backend-hpa.yaml @@ -2,32 +2,39 @@ apiVersion: {{ ternary "autoscaling/v2" "autoscaling/v2beta2" (.Capabilities.APIVersions.Has "autoscaling/v2") }} kind: HorizontalPodAutoscaler metadata: + {{- with .Values.defaultBackend.autoscaling.annotations }} + annotations: {{ toYaml . | nindent 4 }} + {{- end }} labels: {{- include "ingress-nginx.labels" . | nindent 4 }} app.kubernetes.io/component: default-backend {{- with .Values.defaultBackend.labels }} {{- toYaml . | nindent 4 }} {{- end }} - name: {{ template "ingress-nginx.defaultBackend.fullname" . }} + name: {{ include "ingress-nginx.defaultBackend.fullname" . }} namespace: {{ .Release.Namespace }} spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment - name: {{ template "ingress-nginx.defaultBackend.fullname" . }} + name: {{ include "ingress-nginx.defaultBackend.fullname" . }} minReplicas: {{ .Values.defaultBackend.autoscaling.minReplicas }} maxReplicas: {{ .Values.defaultBackend.autoscaling.maxReplicas }} metrics: -{{- with .Values.defaultBackend.autoscaling.targetCPUUtilizationPercentage }} - - type: Resource - resource: - name: cpu - targetAverageUtilization: {{ . }} -{{- end }} -{{- with .Values.defaultBackend.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - targetAverageUtilization: {{ . }} -{{- end }} + {{- with .Values.defaultBackend.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ . }} + {{- end }} + {{- with .Values.defaultBackend.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ . }} + {{- end }} {{- end }}