{{- if .Values.verticalPodAutoscaler.enabled }}
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: {{ include "grpc-graphql-gateway.fullname" . }}
  labels:
    {{- include "grpc-graphql-gateway.labels" . | nindent 4 }}
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: {{ include "grpc-graphql-gateway.fullname" . }}
  updatePolicy:
    updateMode: {{ .Values.verticalPodAutoscaler.updateMode }}
  resourcePolicy:
    containerPolicies:
    - containerName: {{ .Chart.Name }}
      {{- if .Values.verticalPodAutoscaler.minAllowed }}
      minAllowed:
        {{- toYaml .Values.verticalPodAutoscaler.minAllowed | nindent 8 }}
      {{- end }}
      {{- if .Values.verticalPodAutoscaler.maxAllowed }}
      maxAllowed:
        {{- toYaml .Values.verticalPodAutoscaler.maxAllowed | nindent 8 }}
      {{- end }}
      {{- if .Values.verticalPodAutoscaler.controlledResources }}
      controlledResources:
        {{- toYaml .Values.verticalPodAutoscaler.controlledResources | nindent 8 }}
      {{- end }}
      mode: {{ .Values.verticalPodAutoscaler.containerMode | default "Auto" }}
{{- end }}
