{{- if .Values.hpa.worker.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: {{ include "sure.fullname" . }}-worker
  labels:
    {{- include "sure.labels" . | nindent 4 }}
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: {{ include "sure.fullname" . }}-worker
  minReplicas: {{ .Values.hpa.worker.minReplicas }}
  maxReplicas: {{ .Values.hpa.worker.maxReplicas }}
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: {{ .Values.hpa.worker.targetCPUUtilizationPercentage }}
{{- end }}
