{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if and .Values.prometheus.enabled .Values.prometheus.pdb.create }}
apiVersion: {{ include "common.capabilities.policy.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
  name: {{ template "kube-prometheus.prometheus.fullname" . }}
  namespace: {{ include "common.names.namespace" . | quote }}
  labels: {{- include "kube-prometheus.prometheus.labels" . | nindent 4 }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
spec:
  selector:
    matchLabels: {{- include "kube-prometheus.prometheus.matchLabels" . | nindent 6 }}
  {{- if .Values.prometheus.pdb.minAvailable }}
  minAvailable: {{ .Values.prometheus.pdb.minAvailable }}
  {{- end }}
  {{- if or .Values.prometheus.pdb.maxUnavailable ( not .Values.prometheus.pdb.minAvailable ) }}
  maxUnavailable: {{ .Values.prometheus.pdb.maxUnavailable | default 1 }}
  {{- end }}
{{- end }}
