{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: {{ include "datadog-operator.fullname" . }}
  labels:
{{ include "datadog-operator.labels" . | indent 4 }}
rules:
- apiGroups:
  - ""
  resources:
  - pods
  - services
  - endpoints
  - events
  - configmaps
  - secrets
  - serviceaccounts
  verbs:
  - '*'
- apiGroups:
  - apps
  resources:
  - deployments
  - daemonsets
  verbs:
  - '*'
- apiGroups:
  - rbac.authorization.k8s.io
  - roles.rbac.authorization.k8s.io
  - authorization.k8s.io
  resources:
  - 'roles'
  - 'rolebindings'
  verbs:
  - '*'
- apiGroups:
  - policy
  resources:
  - poddisruptionbudgets
  verbs:
  - '*'
- apiGroups:
  - datadoghq.com
  resources:
  - 'datadogagents'
  - 'datadogagents/status'
  - 'datadogagents/finalizers'
  - 'extendeddaemonsets'
  verbs:
  - '*'
{{- end -}}
