{{- if and .Values.deployment.enabled .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ template "coredns.serviceAccountName" . }}
  labels: {{- include "coredns.labels" . | nindent 4 }}
  {{- if or .Values.serviceAccount.annotations .Values.customAnnotations }}
  annotations:
    {{- if .Values.customAnnotations }}
    {{- toYaml .Values.customAnnotations | nindent 4 }}
    {{- end }}
    {{- if .Values.serviceAccount.annotations }}
    {{- toYaml .Values.serviceAccount.annotations | nindent 4 }}
    {{- end }}
  {{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
  - name: {{ . }}
{{- end }}
{{- end }}
{{- end }}
