diff --git a/helm/templates/hpa.yaml b/helm/templates/hpa.yaml new file mode 100644 index 0000000..dd2c56a --- /dev/null +++ b/helm/templates/hpa.yaml @@ -0,0 +1,38 @@ +{{- if and .Values.autoscaling.enabled (or .Values.autoscaling.cpu.enabled .Values.autoscaling.memory.enabled) }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "app.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "app.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "app.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.cpu.enabled }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.cpu.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.memory.enabled }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.memory.targetMemoryUtilizationPercentage }} + {{- end }} + {{- with .Values.autoscaling.behavior }} + behavior: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} + diff --git a/helm/values.yaml b/helm/values.yaml index 99b0d66..0af7939 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -64,6 +64,18 @@ tolerations: [] affinity: {} +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 2 + cpu: + enabled: true + targetCPUUtilizationPercentage: 70 + memory: + enabled: false + targetMemoryUtilizationPercentage: 80 + behavior: {} + # Environment variables to pass to the hub container env: [] # - name: DEBUG