{{- if .Values.serviceAccount.create }}
{{- $root := . -}}
apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    {{- include "grafana.labels" . | nindent 4 }}
    {{- with .Values.serviceAccount.labels }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
  {{- with .Values.serviceAccount.annotations }}
  annotations:
    {{- tpl (toYaml . | nindent 4) $root }}
  {{- end }}
  name: {{ include "grafana.serviceAccountName" . }}
  namespace: {{ include "grafana.namespace" . }}
{{- end }}
