{{- if and .Values.coreDns.enabled .Values.coreDns.service.enabled }}
apiVersion: v1
kind: Service
metadata:
  name: {{ template "kube-prometheus.fullname" . }}-coredns
  namespace: {{ .Values.coreDns.namespace }}
  labels: {{- include "kube-prometheus.labels" . | nindent 4 }}
    app.kubernetes.io/component: {{ template "kube-prometheus.fullname" . }}-coredns
spec:
  clusterIP: None
  ports:
    - name: http-metrics
      port: {{ .Values.coreDns.service.port }}
      protocol: TCP
      targetPort: {{ .Values.coreDns.service.targetPort }}
  selector:
    {{- if .Values.coreDns.service.selector }}
{{ toYaml .Values.coreDns.service.selector | indent 4 }}
    {{- else }}
    k8s-app: kube-dns
    {{- end }}
{{- end }}
