{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: {{ template "kyverno.fullname" . }}:leaderelection
  namespace: {{ template "kyverno.namespace" . }}
  labels: {{ include "kyverno.labels" . | nindent 4 }}
    app: kyverno
rules:
- apiGroups:
  - coordination.k8s.io
  resources:
  - leases
  verbs:
  - create
  - delete
  - get
  - patch
  - update
# Allow update of Kyverno deployment annotations
- apiGroups:
    - apps
  resources:
    - deployments
  verbs:
    - get
    - list
    - patch
    - update
    - watch

{{- end }}
