{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  name: {{ template "kubeless.fullname" . }}-controller-deployer
  labels:
{{ include "labels.standard" . | indent 4 }}
rules:
- apiGroups:
  - ""
  resources:
  - services
  - configmaps
  verbs:
  - create
  - get
  - delete
  - list
  - update
  - patch
- apiGroups:
  - apps
  - extensions
  resources:
  - deployments
  verbs:
  - create
  - get
  - delete
  - list
  - update
  - patch
- apiGroups:
  - ""
  resources:
  - pods
  verbs:
  - list
  - delete
- apiGroups:
  - ""
  resourceNames:
  - kubeless-registry-credentials
  resources:
  - secrets
  verbs:
  - get
- apiGroups:
  - kubeless.io
  resources:
  - functions
  - httptriggers
  - cronjobtriggers
  verbs:
  - get
  - list
  - watch
  - update
  - delete
- apiGroups:
  - batch
  resources:
  - cronjobs
  - jobs
  verbs:
  - create
  - get
  - delete
  - deletecollection
  - list
  - update
  - patch
- apiGroups:
  - autoscaling
  resources:
  - horizontalpodautoscalers
  verbs:
  - create
  - get
  - delete
  - list
  - update
  - patch
- apiGroups:
  - apiextensions.k8s.io
  resources:
  - customresourcedefinitions
  verbs:
  - get
  - list
- apiGroups:
  - monitoring.coreos.com
  resources:
  - alertmanagers
  - prometheuses
  - servicemonitors
  verbs:
  - '*'
- apiGroups:
  - extensions
  resources:
  - ingresses
  verbs:
  - create
  - get
  - list
  - update
  - delete
{{- end}}
