{{- if .Values.managedServiceAccount }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: {{ template "metricbeat.serviceAccount" . }}-cluster-role
  labels:
    app: "{{ template "metricbeat.fullname" . }}"
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    heritage: {{ .Release.Service | quote }}
    release: {{ .Release.Name | quote }}
rules: {{ toYaml .Values.clusterRoleRules | nindent 2 -}}
{{- end -}}
