{{- if and (or .Values.deployment.kong.enabled .Values.ingressController.enabled) .Values.deployment.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ template "kong.serviceAccountName" . }}
  namespace: {{ template "kong.namespace" . }}
  {{- if .Values.deployment.serviceAccount.annotations }}
  annotations:
  {{- range $key, $value := .Values.deployment.serviceAccount.annotations }}
    {{ $key }}: {{ $value | quote }}
  {{- end }}
  {{- end }}
  labels:
    {{- include "kong.metaLabels" . | nindent 4 }}
{{- end -}}
