{{- if .Values.worker.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    app.kubernetes.io/component: worker-autoscaler
  name: {{ include "common.names.fullname" . }}-autoscaler
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: statefulset
    name: {{ include "common.names.fullname" . }}-worker
  minReplicas: {{ .Values.worker.replicaCount }}
  maxReplicas: {{ .Values.worker.autoscaling.replicasMax }}
  metrics:
    - type: Resource
      resource:
        name: cpu
        targetAverageUtilization: {{ .Values.worker.autoscaling.CpuTargetPercentage }}
{{- end }}
