{{- if .Values.autoscaling.enabled }}
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: {{ template "formbricks.name" . }}
  labels:
    {{- include "formbricks.labels" . | nindent 4 }}
    {{- with .Values.autoscaling.additionalLabels }}
      {{- toYaml . | nindent 4 }}
    {{- end }}
  {{- if .Values.autoscaling.annotations }}
  annotations:
    {{- toYaml .Values.autoscaling.annotations | nindent 4 }}
  {{- end }}
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: {{ template "formbricks.name" . }}
  minReplicas: {{ .Values.autoscaling.minReplicas }}
  maxReplicas: {{ .Values.autoscaling.maxReplicas }}
  metrics:
    {{- toYaml .Values.autoscaling.metrics | nindent 4 }}
  {{- if .Values.autoscaling.behavior }}
  behavior:
    {{- toYaml .Values.autoscaling.behavior | nindent 4 }}
  {{- end }}
{{- end }}
