Jump to content

CoreDNS

From Wikitech

CoreDNS is the DNS server we use in kubernetes. It provides DNS services for both internal clients (like Kubernetes Pods) and external clients (like our DNS recursors which delegate PTR zones to CoreDNS).

Components:

Operations

CoredDNS is running as a regular deployment with multiple replicas trying to span multiple datacenter rows. By default the kube-dns service is made available via NodePort on port 53 (TCP and UDP).

By default our CoreDNS configuration forwards all requests it can't answer to out resolvers based on what is configured in /etc/resolv.conf on the kubernetes workers.

For details/context on how the delegation from the recursors is set up, see: T344171 Reverse DNS for k8s pods IPs

Plugins/Extras

In addition to the standard set of CoreDNS plugins and configuration required for working with Kubernetes, we enable:

nsid: Queried with dig +nsid CoreDNS will respond with the pod name which answered the query.

reflect.k8s.local.wmnet: A fake zone reflect.k8s.local.wmnet that is served by the whoami plugin. Like the reflect.wikimedia.org zone, this synthesizes a response with an A/AAAA record of the client IP as seen by coredns, and a SRV record with the source port number and protocol.

internal_only: A variant of CoreDNS that only resolves cluster internal and *.wmnet names. Anything outside of those will be answered with NXDOMAIN.

CoreDNSUpstreamHealthcheckFailures

This alert is triggered when health checking the upstream DNS server (our multicast DNS IP) failed consecutively for a particular CoreDNS instance. We have observed this behavior during network congestion (and other generic networking issues) on kubernetes worker nodes (see: https://phabricator.wikimedia.org/T439575).

Worth checking is the CoreDNS logstash dashboard where you might see errors from the forwarder plugin that issues the metrics backing this alert.

You may want to try deleting a misbehaving CoreDNS pod to schedule a replacement on a different node (if only specific Pods are affected).

deploy2003:~$ kube-env admin CLUSTER
deploy2003:~$ kubectl -n kube-system delete po <CoreDNS-Pod-Name>


Building a new version

We usually run the CoreDNS version that kubeadm installs by default for a particular Kubernetes version. Building a new version requires updating the container image as well as maybe updating the coredns helm chart. Although the latter is not usually required.