CoreDNS: Flexible DNS Server for Dynamic Environments

K8s Guru
2 min read
CoreDNS: Flexible DNS Server for Dynamic Environments

Introduction

CoreDNS arrives as a fast, extensible DNS server with a plugin architecture. It’s designed to adapt to dynamic environments and integrates cleanly with Kubernetes service discovery.

Features

  • Plugins for caching, rewriting, metrics, and Kubernetes lookup.
  • Single Binary, Simple Config via a Corefile with composable directives.
  • Observability with Prometheus metrics out of the box.
  • Kubernetes Plugin: Serves cluster.local directly from the API server, respecting namespaces, headless services, and pod records.

Corefile Example

. {
  kubernetes cluster.local in-addr.arpa ip6.arpa {
    pods verified
    fallthrough in-addr.arpa ip6.arpa
  }
  rewrite name mTLS.example.local svc.example.local
  cache 30
  prometheus :9153
  forward . 8.8.8.8 8.8.4.4
  log
}

Migrating from kube-dns

  • Swap the Deployment/Service in kube-system with the official CoreDNS manifests; both respond on port 53/UDP/TCP.
  • Validate stub domains and upstream forwarders—CoreDNS expresses them via the forward plugin instead of ConfigMap stubDomains.
  • Watch for feature parity gaps: federation domains require an extra plugin, and negative caching defaults differ from kube-dns.

Performance Notes

  • Plugin ordering matters: place cache near the top to minimize API lookups.
  • Horizontal scaling is straightforward—run multiple replicas behind a ClusterIP or headless Service for kube-proxy round robin.
  • Enable prometheus to export query latency and error counters, then scrape with Prometheus for early warning signals.

Conclusion

DNS is foundational. CoreDNS’s modular design is well‑suited to container platforms in 2016.