From 3077a1d304c2d6b57771e78976420c6ab0c8f059 Mon Sep 17 00:00:00 2001 From: David Burke Date: Sun, 7 Feb 2021 16:48:32 -0500 Subject: [PATCH] Update to autoscaling/v2beta1 syntax for hpa --- templates/web-hpa.yaml | 29 +++++++++++++++++++---------- templates/worker-hpa.yaml | 33 +++++++++++++++++++++------------ values.yaml | 19 +++++++++++-------- 3 files changed, 51 insertions(+), 30 deletions(-) diff --git a/templates/web-hpa.yaml b/templates/web-hpa.yaml index f24629d..d737434 100644 --- a/templates/web-hpa.yaml +++ b/templates/web-hpa.yaml @@ -1,19 +1,28 @@ -{{- if .Values.web.hpa.enabled -}} -apiVersion: autoscaling/v1 +{{- if .Values.web.autoscaling.enabled -}} +apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler metadata: name: {{ template "glitchtip.fullname" . }} labels: - app: {{ template "glitchtip.fullname" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" - release: "{{ .Release.Name }}" - heritage: "{{ .Release.Service }}" + {{- include "glitchtip.labels" . | nindent 4 }} spec: scaleTargetRef: - kind: Deployment apiVersion: apps/v1 + kind: Deployment name: {{ template "glitchtip.fullname" . }} - minReplicas: {{ .Values.web.hpa.minpods }} - maxReplicas: {{ .Values.web.hpa.maxpods }} - targetCPUUtilizationPercentage: {{ .Values.web.hpa.cputhreshold }} + minReplicas: {{ .Values.web.autoscaling.minReplicas }} + maxReplicas: {{ .Values.web.autoscaling.maxReplicas }} + metrics: + {{- if .Values.web.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.web.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.web.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.web.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} {{- end }} diff --git a/templates/worker-hpa.yaml b/templates/worker-hpa.yaml index 237977b..0e463d2 100644 --- a/templates/worker-hpa.yaml +++ b/templates/worker-hpa.yaml @@ -1,19 +1,28 @@ -{{- if .Values.worker.hpa.enabled -}} -apiVersion: autoscaling/v1 +{{- if .Values.worker.autoscaling.enabled -}} +apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler metadata: - name: {{ template "glitchtip.fullname" . }}-worker + name: {{ template "glitchtip.fullname" . }} labels: - app: {{ template "glitchtip.fullname" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" - release: "{{ .Release.Name }}" - heritage: "{{ .Release.Service }}" + {{- include "glitchtip.labels" . | nindent 4 }} spec: scaleTargetRef: - kind: Deployment apiVersion: apps/v1 + kind: Deployment name: {{ template "glitchtip.fullname" . }}-worker - minReplicas: {{ .Values.worker.hpa.minpods }} - maxReplicas: {{ .Values.worker.hpa.maxpods }} - targetCPUUtilizationPercentage: {{ .Values.worker.hpa.cputhreshold }} -{{- end }} + minReplicas: {{ .Values.worker.autoscaling.minReplicas }} + maxReplicas: {{ .Values.worker.autoscaling.maxReplicas }} + metrics: + {{- if .Values.worker.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.worker.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.worker.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.worker.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/values.yaml b/values.yaml index 28a0043..dc36b1a 100644 --- a/values.yaml +++ b/values.yaml @@ -23,11 +23,13 @@ environmentVariables: web: replicaCount: 1 - hpa: + autoscaling: enabled: false - cputhreshold: 70 - minpods: 2 - maxpods: 4 + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + # budget: # minAvailable: 1 resources: @@ -52,11 +54,12 @@ web: worker: replicaCount: 1 - hpa: + autoscaling: enabled: false - cputhreshold: 90 - minpods: 1 - maxpods: 4 + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 90 + # targetMemoryUtilizationPercentage: 80 resources: {} # limits: