{{ if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: {{ template "kubedb.fullname" . }}
  labels:
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    app: "{{ template "kubedb.name" . }}"
    heritage: "{{ .Release.Service }}"
    release: "{{ .Release.Name }}"
rules:
- apiGroups:
  - apiextensions.k8s.io
  resources:
  - customresourcedefinitions
  verbs: ["create", "delete", "get", "list"]
- apiGroups:
  - rbac.authorization.k8s.io
  resources:
  - rolebindings
  - roles
  verbs: ["create", "delete", "get", "patch"]
- apiGroups:
  - ""
  resources:
  - services
  verbs: ["create", "delete", "get", "patch"]
- apiGroups:
  - ""
  resources:
  - secrets
  - serviceaccounts
  verbs: ["create", "delete", "get", "patch"]
- apiGroups:
  - apps
  resources:
  - deployments
  - statefulsets
  verbs: ["create", "delete", "get", "patch", "update"]
- apiGroups:
  - batch
  resources:
  - jobs
  verbs: ["create", "delete", "get", "list", "watch"]
- apiGroups:
  - storage.k8s.io
  resources:
  - storageclasses
  verbs: ["get"]
- apiGroups:
  - ""
  resources:
  - pods
  verbs: ["deletecollection", "get", "list", "patch", "watch"]
- apiGroups:
  - ""
  resources:
  - persistentvolumeclaims
  verbs: ["create", "delete", "get", "list", "patch", "watch"]
- apiGroups:
  - ""
  resources:
  - configmaps
  verbs: ["create", "delete", "get", "update"]
- apiGroups:
  - ""
  resources:
  - events
  verbs: ["create"]
- apiGroups:
  - ""
  resources:
  - nodes
  verbs: ["get", "list", "watch"]
- apiGroups:
  - kubedb.com
  resources:
  - '*'
  verbs: ['*']
- apiGroups:
  - monitoring.coreos.com
  resources:
  - servicemonitors
  verbs: ["create", "delete", "get", "list", "update"]
{{ end }}
