{{- if and .Values.rbac.create .Values.collector.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  labels:
    app.kubernetes.io/name : {{ template "wavefront.fullname" . }}
    helm.sh/chart: {{ template "wavefront.chart" . }}
    app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
    app.kubernetes.io.instance: {{ .Release.Name | quote }}
    app.kubernetes.io/component: collector
    kubernetes.io/bootstrapping: rbac-defaults
  annotations:
    rbac.authorization.kubernetes.io/autoupdate: "true"
  name: {{ template "wavefront.collector.fullname" . }}
rules:
- apiGroups:
  - ""
  resources:
  - events
  - namespaces
  - nodes
  - nodes/stats
  - pods
  - services
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - ""
  resources:
  - configmaps
  verbs:
  - get
  - update
  - create
- apiGroups:
  - extensions
  resources:
  - deployments
  verbs:
  - get
  - list
  - watch
- nonResourceURLs: ["/metrics"]
  verbs:
  - get
{{- end }}
