{{- if .Values.freeleaps.vpa }}
---
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: {{ .Release.Name }}-freeleaps-vpa
  namespace: {{ .Release.Namespace }}
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: freeleaps
  resourcePolicy:
    containerPolicies:
      - containerName: '*'
        {{- if .Values.freeleaps.vpa.minAllowed.enabled }}
        minAllowed:
          cpu: {{ .Values.freeleaps.vpa.minAllowed.cpu }}
          memory: {{ .Values.freeleaps.vpa.minAllowed.memory }}
        {{- end }}
        {{- if .Values.freeleaps.vpa.maxAllowed.enabled }}
        maxAllowed:
          cpu: {{ .Values.freeleaps.vpa.maxAllowed.cpu }}
          memory: {{ .Values.freeleaps.vpa.maxAllowed.memory }}
        {{- end }}
        {{- if .Values.freeleaps.vpa.controlledResources }}
        controlledResources:
          {{- range .Values.freeleaps.vpa.controlledResources }}
          - {{ . }}
          {{- end }}
        {{- end }}
{{- end }}