<p>I remember DNS records being cached locally on various linux distros in the past, but this appears to have changed over the years (<a href="https://stackoverflow.com/questions/11020027/dns-caching-in-linux">DNS caching in linux</a>). </p>

<p>Within our environment (non-K8S) we found a noticeable delay (1-2ms) for each request due to DNS lookups because of this.</p>

<p>I also noticed there is no local DNS cache within K8S by default (<a href="https://github.com/kubernetes/kubernetes/issues/45363" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/issues/45363</a>) and the DNS cache within CoreOS is also disabled by default (<a href="https://coreos.com/os/docs/latest/configuring-dns.html" rel="nofollow noreferrer">https://coreos.com/os/docs/latest/configuring-dns.html</a>).</p>

<p>Given we're considering migrating towards K8S I was wondering; why is this not enabled for Kubernetes in particular?</p>

<p>My only theory is within kube-dns records are updated pre-emptively to ensure high-availability; but I'm not sure if K8S actually does that?</p>

<p>As a workaround, if I were to run dnsmasq on every node, would I break things? I noticed there have been attempts to make that setup the default within K8S, but those attempts/PR's appear to have gone stale and I'm not sure why.</p>

Niels Krijger
<p>Since <code>Kubernetes 1.9+</code> was announced, <a href="https://coredns.io/" rel="nofollow noreferrer">CoreDNS</a> had been included in <code>kubeadm</code>, <code>minikube</code> tools, etc. as a default DNS server and replaced former <code>kube-dns</code> (which was based on <code>dnsmasq</code>). </p>

<p>It was built as a fork of the <a href="https://caddyserver.com/" rel="nofollow noreferrer">Caddy</a> web server and middleware chains in a way that each middleware component carries some DNS feature. If you already use <code>kube-dns</code>, it is possible to launch <code>CoreDNS</code> using this <a href="https://github.com/coredns/deployment/tree/master/kubernetes" rel="nofollow noreferrer">Link</a>. </p>

<p>CoreDNS is already equipped with caching and forwarding features, assuming that caching runs as a separate component, and brokes dependency for using <code>dnsmasq</code>.</p>

<pre><code>. {
    proxy . 8.8.8.8:53
    cache example.org
}
</code></pre>

<p>There are a lot of <a href="https://coredns.io/plugins/" rel="nofollow noreferrer">plugins</a> which you can use extending DNS functionality, like proxying requests, rewriting requests, doing health checks on endpoints, and publishing metrics into <a href="https://prometheus.io/" rel="nofollow noreferrer">Prometheus</a>.</p>
