apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: {{ tuple . "" | include "benji.fullname" }}
  labels:
    app.kubernetes.io/name: {{ include "benji.name" . }}
    helm.sh/chart: {{ include "benji.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
rules:
- apiGroups:
  - ""
  resources:
  - persistentvolumes
  - persistentvolumeclaims
  - pods
  verbs:
  - get
  - list
  - watch
- apiGroups:
    - ""
  resources:
    - persistentvolumeclaims
  verbs:
    - create
- apiGroups:
    - ""
  resources:
    - events
  verbs:
    - create
- apiGroups:
  - storage.k8s.io
  resources:
  - storageclasses
  verbs:
  - get
  - list
  - watch
{{- if .Values.fsfreeze.enabled }}
- apiGroups:
  - ""
  resources:
  - pods/exec
  verbs:
  - create
  # Also needs GET where kubectl doesn't, see https://github.com/kubernetes-client/python/issues/690#issuecomment-459010364
  - get
{{- end}}
