apiVersion: v1
kind: Service
metadata:
  name: {{ template "coredns.fullname" . }}
  labels:
    app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
    app.kubernetes.io/instance: {{ .Release.Name | quote }}
    helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    {{- if .Values.isClusterService }}
    k8s-app: {{ .Chart.Name | quote }}
    kubernetes.io/cluster-service: "true"
    kubernetes.io/name: "CoreDNS"
    {{- end }}
    app.kubernetes.io/name: {{ template "coredns.name" . }}
{{- if .Values.customLabels }}
{{ toYaml .Values.customLabels | indent 4 }}
{{- end }}
  annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
spec:
  selector:
    app.kubernetes.io/instance: {{ .Release.Name | quote }}
    {{- if .Values.isClusterService }}
    k8s-app: {{ .Chart.Name | quote }}
    {{- end }}
    app.kubernetes.io/name: {{ template "coredns.name" . }}
  {{- if .Values.service.clusterIP }}
  clusterIP: {{ .Values.service.clusterIP }}
  {{- end }}
  {{- if .Values.service.externalIPs }}
  externalIPs:
  {{ toYaml .Values.service.externalIPs | indent 4 }}
  {{- end }}
  {{- if .Values.service.externalTrafficPolicy }}
  externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}
  {{- end }}
  {{- if .Values.service.loadBalancerIP }}
  loadBalancerIP: {{ .Values.service.loadBalancerIP }}
  {{- end }}
  ports:
{{ include "coredns.servicePorts" . | indent 2 -}}
  type: {{ default "ClusterIP" .Values.serviceType }}
