{{- if .Values.coreDns.enabled }}
apiVersion: {{ printf "%s/v1" (.Values.prometheusOperator.crdApiGroup | default "monitoring.coreos.com") }}
kind: ServiceMonitor
metadata:
  name: {{ template "prometheus-operator.fullname" . }}-coredns
  labels:
    app: {{ template "prometheus-operator.name" . }}-coredns
{{ include "prometheus-operator.labels" . | indent 4 }}
spec:
  jobLabel: jobLabel
  selector:
    matchLabels:
      app: {{ template "prometheus-operator.name" . }}-coredns
      release: {{ .Release.Name | quote }}
  namespaceSelector:
    matchNames:
      - "kube-system"
  endpoints:
  - port: http-metrics
    interval: 15s
    bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
{{- end }}
