{{- if .Values.managedServiceAccount }}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ template "metricbeat.serviceAccount" . }}
  annotations:
    {{- with .Values.serviceAccountAnnotations }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
  labels:
    app: "{{ template "metricbeat.fullname" . }}"
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    heritage: {{ .Release.Service | quote }}
    release: {{ .Release.Name | quote }}
{{- end -}}
