{{- if .Values.podDisruptionBudget.enabled }}
{{- if .Capabilities.APIVersions.Has "policy/v1/PodDisruptionBudget" }}
apiVersion: policy/v1
{{- else -}}
apiVersion: policy/v1beta1
{{- end }}
kind: PodDisruptionBudget
metadata:
  name: {{ include "vm-operator.fullname" . }}
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "vm-operator.labels" . | nindent 4 }}
  {{- with .Values.podDisruptionBudget.labels }}
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
{{- if .Values.podDisruptionBudget.minAvailable }}
  minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
{{- end }}
{{- if .Values.podDisruptionBudget.maxUnavailable }}
  maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }}
{{- end }}
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ include "vm-operator.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}