{{- if .Values.podSecurityPolicy.create }}
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: Role
metadata:
  name: {{ template "elastalert.fullname" . }}
  labels:
    app: {{ template "elastalert.name" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
rules:
  - apiGroups:
    - policy
    resources:
    - podsecuritypolicies
    resourceNames:
    - {{ template "elastalert.fullname" . }}
    verbs:
    - use
{{- end -}}
