# grafana_charts_grafana-agent-cluster-role-binding.yaml
{{- with (.Values.metaMonitoring).grafanaAgent }}
{{- if .enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: {{ include "tempo.resourceName" (dict "ctx" $ "component" "grafana-agent") }}
  namespace: {{ .namespace | default $.Release.Namespace | quote }}
  labels:
    {{- include "tempo.labels" (dict "ctx" $ "component" "meta-monitoring" ) | nindent 4 }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ include "tempo.resourceName" (dict "ctx" $ "component" "grafana-agent") }}
subjects:
  - kind: ServiceAccount
    name: {{ include "tempo.resourceName" (dict "ctx" $ "component" "grafana-agent") }}
    namespace: {{ .namespace | default $.Release.Namespace }}
{{- end }}
{{- end }}