{{- if and .Values.rbac.create .Values.rbac.pspEnabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: {{ include "promtail.fullname" . }}-psp
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "promtail.labels" . | nindent 4 }}
rules:
  - apiGroups:
      - policy
    resources:
      - podsecuritypolicies
    verbs:
      - use
    resourceNames:
      - {{ include "promtail.fullname" . }}
{{- end }}
