From c4a1ac2b1f76b7720bb794fdb093c5e7a267bd2c Mon Sep 17 00:00:00 2001 From: Charlie Haley Date: Thu, 11 Jan 2024 19:40:08 +0000 Subject: [PATCH] feat: make HPA metrics generic (#66) Signed-off-by: Charlie Haley --- templates/hpa.yaml | 22 +++------------------- values.yaml | 44 ++++++++++++++++++++++---------------------- 2 files changed, 25 insertions(+), 41 deletions(-) diff --git a/templates/hpa.yaml b/templates/hpa.yaml index 848dc44..6f97803 100644 --- a/templates/hpa.yaml +++ b/templates/hpa.yaml @@ -12,26 +12,10 @@ spec: name: {{ include "benthos.fullname" . }} minReplicas: {{ .Values.autoscaling.minReplicas }} maxReplicas: {{ .Values.autoscaling.maxReplicas }} + {{- with .Values.autoscaling.metrics }} metrics: - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} - {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- end }} - {{- with .Values.autoscaling.customMetric -}} - {{ toYaml . | nindent 4 }} - {{- end }} + {{- toYaml . | nindent 4 }} + {{- end }} {{- with .Values.autoscaling.behavior }} behavior: {{- toYaml . | nindent 4 }} diff --git a/values.yaml b/values.yaml index 7aaa447..0abc773 100644 --- a/values.yaml +++ b/values.yaml @@ -2,8 +2,7 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. - -deployment: +deployment: replicaCount: 1 podAnnotations: {} podLabels: {} @@ -12,8 +11,6 @@ deployment: # Default 60. ref: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/ terminationGracePeriodSeconds: 60 - - # commonLabels -- Add additional labels to all created resources. commonLabels: {} @@ -103,24 +100,27 @@ resources: {} autoscaling: enabled: false minReplicas: 1 - maxReplicas: 100 - targetCPUUtilizationPercentage: 80 - # targetMemoryUtilizationPercentage: 80 - - # autoscaling.customMetric -- Target a custom metric for autoscaling. - customMetric: {} - # - type: Pods - # pods: - # metric: - # name: utilization - # target: - # type: AverageValue - # averageValue: 95 - - # autoscaling.behavior -- Configure separate scale-up and scale-down behaviors. - behavior: {} - # scaleDown: - # stabilizationWindowSeconds: 300 + maxReplicas: 12 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 80 +# - type: Resource +# resource: +# name: memory +# target: +# type: Utilization +# averageUtilization: 80 +# behavior: +# scaleDown: +# stabilizationWindowSeconds: 300 +# policies: +# - type: Pods +# value: 1 +# periodSeconds: 60 nodeSelector: {}