{{- range $svcName := list "gitdata" "gitpod" "gitsync" "email" }} {{- $svcCfg := index $.Values $svcName }} {{- $hpaCfg := index $.Values.autoscaling $svcName }} {{- if and $svcCfg.enabled $hpaCfg.enabled }} --- apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: {{ include "app.serviceFullname" (dict "root" $ "name" $svcName) }} namespace: {{ include "app.namespace" $ }} labels: {{- include "app.serviceLabels" (dict "root" $ "name" $svcName) | nindent 4 }} spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: {{ include "app.serviceFullname" (dict "root" $ "name" $svcName) }} minReplicas: {{ $hpaCfg.minReplicas }} maxReplicas: {{ $hpaCfg.maxReplicas }} metrics: {{- if $hpaCfg.targetCPUUtilizationPercentage }} - type: Resource resource: name: cpu target: type: Utilization averageUtilization: {{ $hpaCfg.targetCPUUtilizationPercentage }} {{- end }} {{- if $hpaCfg.targetMemoryUtilizationPercentage }} - type: Resource resource: name: memory target: type: Utilization averageUtilization: {{ $hpaCfg.targetMemoryUtilizationPercentage }} {{- end }} {{- end }} {{- end }}