{{- $pspAvailable := (semverCompare "<1.25-0" (include "common.capabilities.kubeVersion" .)) -}}
{{- if and $pspAvailable .Values.operator.enabled .Values.rbac.create .Values.rbac.pspEnabled }}
kind: ClusterRole
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
metadata:
  name: {{ template "kube-prometheus.operator.fullname" . }}-psp
  labels: {{- include "kube-prometheus.operator.labels" . | nindent 4 }}
rules:
  - apiGroups: ['extensions']
    resources: ['podsecuritypolicies']
    verbs: ['use']
    resourceNames:
      - {{ template "kube-prometheus.operator.fullname" . }}
{{- end }}
