{{- if .Values.hpa.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
  name: {{ template "appmesh-gateway.fullname" . }}
  labels:
{{ include "appmesh-gateway.labels" . | indent 4 }}
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: {{ template "appmesh-gateway.fullname" . }}
  minReplicas: {{ .Values.replicaCount }}
  maxReplicas: {{ .Values.hpa.maxReplicas }}
  metrics:
    {{- if .Values.hpa.cpu }}
    - type: Resource
      resource:
        name: cpu
        targetAverageUtilization: {{ .Values.hpa.cpu }}
    {{- end }}
    {{- if .Values.hpa.memory }}
    - type: Resource
      resource:
        name: memory
        targetAverageValue: {{ .Values.hpa.memory }}
    {{- end }}
{{- end }}
