{{- if or (.Values.clusterRole.create) (.Values.presets.kubernetesAttributes.enabled) (.Values.presets.clusterMetrics.enabled) (.Values.presets.kubeletMetrics.enabled) (.Values.presets.kubernetesEvents.enabled) -}} apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: {{ include "opentelemetry-collector.clusterRoleBindingName" . }} labels: {{- include "opentelemetry-collector.labels" . | nindent 4 }} {{- if .Values.clusterRole.clusterRoleBinding.annotations }} annotations: {{- range $key, $value := .Values.clusterRole.clusterRoleBinding.annotations }} {{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }} {{- end }} {{- end }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: {{ include "opentelemetry-collector.clusterRoleName" . }} subjects: - kind: ServiceAccount name: {{ include "opentelemetry-collector.serviceAccountName" . }} namespace: {{ include "opentelemetry-collector.namespace" . }} {{- end }}