{{- if .Values.autoScale }}
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: {{ .component.fullName }}
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "nplus.instanceLabels" . | nindent 4 }}
  annotations:
    {{- include "nplus.annotations" . | nindent 4 }}
    {{- include "nplus.argoWave" . | nindent 4 }}
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: StatefulSet
    name: {{ .component.fullName }}
    minReplicas: {{ .Values.replicaCount }}
    maxReplicas: {{ .Values.autoScale }}
  targetCPUUtilizationPercentage: 80
{{- end }}