{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: {{ template "sematext-agent.fullname" . }}
  labels:
    app: {{ template "sematext-agent.name" . }}
    chart: {{ template "sematext-agent.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
rules:
- apiGroups:
  - ""
  resources:
  - events
  - pods
  - pods/log
  verbs:
  - list
  - get
  - watch
{{- if or (.Values.containerToken) (.Values.infraToken) }}
- apiGroups:
  - ""
  resources:
  - configmaps
  - nodes
  - secrets
  verbs:
  - list
  - get
  - watch
- apiGroups:
  - ""
  resources:
  - nodes/metrics
  verbs:
  - get
  - create
- apiGroups:
  - ""
  resources:
  - pods
  - configmaps
  verbs:
  - create
  - delete
  - update
- apiGroups:
  - apps
  resources:
  - deployments
  - replicasets
  verbs:
  - watch
  - list
  - get
- apiGroups:
  - extensions
  resources:
  - replicasets
  verbs:
  - get
  - watch
  - list
{{- end }}
{{- end }}
