{{- if .Values.managedServiceAccount }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: {{ template "apm.serviceAccount" . }}-cluster-role-binding
  labels:
    app: "{{ template "apm.fullname" . }}"
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    heritage: {{ .Release.Service | quote }}
    release: {{ .Release.Name | quote }}
roleRef:
  kind: ClusterRole
  name: {{ template "apm.serviceAccount" . }}-cluster-role
  apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
  name: {{ template "apm.serviceAccount" . }}
  namespace: {{ .Release.Namespace }}
{{- end -}}
