{{- if .Values.podDistuptionBudget.enabled -}}
{{- if or (gt .Values.replicaCount 1.0) ( and (.Values.autoscaling.enabled) (gt .Values.autoscaling.minReplicas 1.0) )  }}
################################################
# Standardized Templates - Pod Disruption Budget (pdb)
# Author/Maintainer: Farley <farley@neonsurge.com>
################################################
apiVersion: {{ template "pdb.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
  name: {{ template "name" . }}
spec:
{{- if .Values.podDistuptionBudget.maxUnavailable }}
  maxUnavailable: {{ .Values.podDistuptionBudget.maxUnavailable }}
{{- end }}
{{- if .Values.podDistuptionBudget.minAvailable }}
  minAvailable: {{ .Values.podDistuptionBudget.minAvailable }}
{{- end }}
  selector:
    matchLabels:
{{- if .Values.usingNewRecommendedLabels }}
{{- if .Values.labelsEnableDefault }}
      app.kubernetes.io/name: {{ template "name" . }}
{{- end }}
{{- else }}
{{- if .Values.labelsEnableDefault }}
      app: {{ template "name" . }}
{{- end }}
{{- end }}

{{- if .Values.labels }}
{{ toYaml .Values.labels | indent 6 }}
{{- end }}
{{- end }}
{{- end }}
