{{- if and .Values.gateway.enabled }}
{{- if or 
  (and (not .Values.gateway.autoscaling.enabled) (gt (int .Values.gateway.replicas) 1)) 
  (and .Values.gateway.autoscaling.enabled (gt (int .Values.gateway.autoscaling.minReplicas) 1))
}}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: {{ include "loki.gatewayFullname" . }}
  namespace: {{ $.Release.Namespace }}
  labels:
    {{- include "loki.gatewayLabels" . | nindent 4 }}
spec:
  selector:
    matchLabels:
      {{- include "loki.gatewaySelectorLabels" . | nindent 6 }}
  maxUnavailable: 1
{{- end }}
{{- end }}
