{{- if and .Values.replicaSet.enabled .Values.replicaSet.pdb.enabled }}
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  labels:
    app: {{ template "mongodb.name" . }}
    chart: {{ template "mongodb.chart" . }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
  name: {{ template "mongodb.fullname" . }}-secondary
spec:
  {{- if .Values.replicaSet.pdb.minAvailable }}
  {{- if .Values.replicaSet.pdb.minAvailable.secondary }}
  minAvailable: {{ .Values.replicaSet.pdb.minAvailable.secondary }}
  {{- end }}
  {{- end }}
  {{- if .Values.replicaSet.pdb.maxUnavailable }}
  {{- if .Values.replicaSet.pdb.maxUnavailable.secondary }}
  maxUnavailable: {{ .Values.replicaSet.pdb.maxUnavailable.secondary }}
  {{- end }}
  {{- end }}
  selector:
    matchLabels:
      app: {{ template "mongodb.name" . }}
      release: {{ .Release.Name }}
      component: secondary
{{- end }}
