{{- if .Values.global.registry.kong.hpa.enabled }}
kind: HorizontalPodAutoscaler
apiVersion: {{ include "horizontalPodAutoscaler.apiVersion" . }}
metadata:
  name: {{ .Chart.Name }}
  labels:
    app: {{ .Chart.Name }}
    relatedNamespace: {{ .Release.Namespace }}
spec:
  scaleTargetRef:
    kind: Deployment
    name: {{ template "kong.fullname" . }}
    apiVersion: apps/v1
  minReplicas: {{ .Values.global.registry.kong.hpa.minReplicas }}
  maxReplicas: {{ .Values.global.registry.kong.hpa.maxReplicas }}
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 60
    - type: Resource
      resource:
        name: memory
        target:
          type: Utilization
          averageUtilization: 90
{{- end }}
