Skip to main content
← PROBLEMS / PRODUCTION-DEBUGGING
An end-to-end domain learning journey

Fixing CoreDNS Query
Flooding from ndots:5.

Kubernetes' default ndots:5 turns every external API lookup (e.g. api.stripe.com) into 4-8 NXDOMAIN search-path queries and triggers glibc A/AAAA UDP conntrack races; deploying NodeLocal DNSCache + ndots:2 cuts CoreDNS QPS by >80% and eliminates 5s timeouts.
Start the journey5 stages
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

If latency budgets leave no room for synchronous retries, set dnsConfig ndots:2 (or trailing dots on external FQDNs) and deploy Kubernetes NodeLocal DNSCache with NOTRACK + TCP upstream to eliminate 5-second UDP conntrack DNS timeouts.

TL;DR30-second simplified summary
▾

Core Mechanics: Kubernetes injects options ndots:5 into every pod's /etc/resolv.conf. Any hostname with fewer than 5 dots—including api.stripe.com (2 dots) or s3.us-east-1.amazonaws.com (4 dots)—is treated as a relative name first.

Visual & Structural Flow: Depicts 6x NXDOMAIN + Conntrack Drop (5s) vs. NodeLocal TCP (<2ms) (App Pod (glibc) -> NodeLocal 169.254.20.10 -> CoreDNS (6 pods)); Pod (ndots:2) -> NodeLocal DNSCache (NOTRACK) -> CoreDNS (TCP) (Pod (ndots:2) -> NodeLocal DNS -> CoreDNS -> Upstream DNS).

Trade-Offs & Production: Scaling CoreDNS from 6 to 30 replicas burns CPU on 280k QPS of NXDOMAINs without fixing the root cause: per-node nf_conntrack UDP packet drops between pods and kube-proxy iptables rules. Production Kubernetes clusters fix both amplification and conntrack races cluster-wide: NodeLocal DNSCache DaemonSet: Listens on link-local 169.254.20.10 per node with.

Failure Modes & Application: DNS amplification and conntrack tuning are essential for high-QPS Kubernetes platforms: Payment & Webhook Egress Clusters: Services calling Stripe, AWS S3, or Twilio at 40,000+ req/s.

Full walkthrough · 5 stages
01
STAGE 01 · WHY IT MATTERSL4 · FUNDAMENTALS

Why ndots:5 floods CoreDNS across 120 Kubernetes nodes.

Why this matters: The mechanism: understand how Why ndots:5 floods CoreDNS across 120 Kubernetes nodes works from first principles.

Kubernetes injects options ndots:5 into every pod's /etc/resolv.conf.

Any hostname with fewer than 5 dots—including api.stripe.com (2 dots) or s3.us-east-1.amazonaws.com (4 dots)—is treated as a relative name first.

02
STAGE 02 · IMPACTL5 · APPLIED DESIGN

What happens during glibc A/AAAA parallel UDP conntrack races.

Why this matters: The problem: see what breaks without What happens during glibc A/AAAA parallel UDP conntrack races under real concurrency or scale.

Two compounding bugs cause intermittent 5-second DNS timeouts:

  1. 8× NXDOMAIN Amplification: Every uncached external lookup generates 3 search-domain NXDOMAIN pairs before trying the root domain.
  2. Parallel A/AAAA Conntrack Race: glibc sends A and AAAA UDP packets from the same source port simultaneously; iptables NAT nf_conntrack races on creating the table entry, silently dropping one packet and forcing a 5-second resolv.conf retry.
ndots:5 Amplification vs. NodeLocal DNSCache

6x NXDOMAIN + Conntrack Drop (5s) vs. NodeLocal TCP (<2ms)

App Pod (glibc)NodeLocal169.254.20.10CoreDNS (6 pods)1. Naive: 6x NXDOMAIN + A/AAAA UDPrace2. Conntrack drop -> 5,000mstimeout!3. Fix (ndots:2): Direct A/AAAA toNodeLocal4. NOTRACK cache hit (<0.5ms) or TCP…

NodeLocal DNSCache bypasses nf_conntrack via NOTRACK and upgrades upstream queries to TCP, eliminating 5s UDP drops.

Engineering Decision Framework
Problem
How to implement Fixing CoreDNS Query Flooding from ndots:5 without hitting unbounded tail latency, state divergence, or operational fragility.
Naive Solution
Use a single unpartitioned path with unbounded retries and synchronous global coordination.
Why It Fails
Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
Alternatives
Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
Engineering Decision
If latency budgets leave no room for synchronous retries, set dnsConfig ndots:2 (or trailing dots on external FQDNs) and deploy Kubernetes NodeLocal DNSCache with NOTRACK + TCP upstream to eliminate 5-second UDP conntrack DNS timeouts.
Trade-Offs
Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
Decision Exercise · Make the Call

When Fixing CoreDNS Query Flooding from ndots:5 experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
STAGE 03 · NAIVE SOLUTIONL5 · APPLIED DESIGN

Naive solution (and why scaling CoreDNS replicas alone fails).

Why this matters: The problem: see what breaks without Naive solution under real concurrency or scale.

Think of Naive solution (and why scaling CoreDNS replicas alone fails) as the intuition layer for Fixing CoreDNS Query Flooding from ndots:5: The problem: see what breaks without Naive solution under real concurrency or scale.

Scaling CoreDNS from 6 to 30 replicas burns CPU on 280k QPS of NXDOMAINs without fixing the root cause: per-node nf_conntrack UDP packet drops between pods and kube-proxy iptables rules.

Design Trade-Off

Naive solution (and why scaling CoreDNS replicas alone fails)

Before · Unbounded Pods & Abrupt Kill
  • 502s during rolling updates
  • ndots:5 DNS flood or OOMKill
  • Unprotected node drains
After · PDB + Probes + Graceful Drain
  • Zero-drop SIGTERM draining
  • Bounded cgroup & conntrack
  • Canary metrics gate rollout
04
STAGE 04 · ENTERPRISE SOLUTIONL6 · SCALE & TRADE-OFFS

Enterprise solution: NodeLocal DNSCache + MutatingWebhook ndots:2 + single-request.

Why this matters: Operational control: configure bounds, failure handling, and safe production defaults.

Production Kubernetes clusters fix both amplification and conntrack races cluster-wide:

  • NodeLocal DNSCache DaemonSet: Listens on link-local 169.254.20.10 per node with iptables NOTRACK (bypassing nf_conntrack completely), caches external TTLs (30–60 s) locally (< 1 ms), and forwards misses to CoreDNS over TCP.
  • Cluster-Wide ndots:2 + single-request-reopen: Inject ndots:2 and single-request-reopen via a Mutating Admission Webhook (or Kyverno policy) so api.stripe.com (2 dots) resolves from root immediately while short names (redis-master, 0 dots) still use cluster search domains.
  • Result: CoreDNS QPS drops by > 80%, 5 s timeouts vanish, and cached p99 stays < 2 ms.
Node-Local DNS Tier

Pod (ndots:2) -> NodeLocal DNSCache (NOTRACK) -> CoreDNS (TCP)

Pod (ndots:2)Root lookup >=2 dotsNodeLocal DNS169.254.20.10 NOTRACKCoreDNSTCP upstream (<20%…Upstream DNS30-60s TTL respected

1.ndots:2 Policy: Eliminates 6x NXDOMAIN searches for external FQDNs without breaking short names.

2.NOTRACK Bypass: Skips Linux nf_conntrack for pod-to-NodeLocal DNS packets.

3.TCP Upstream: Upgrades NodeLocal -> CoreDNS to TCP, eliminating UDP packet drops.

4.single-request-reopen: Serializes glibc A/AAAA on separate sockets for musl/glibc safety.

NodeLocal DNSCache + ndots:2 cuts CoreDNS traffic by > 80% and eliminates conntrack-induced 5-second timeouts.

# Cluster-wide Kyverno / Webhook default injected into Pods (zero app code edits)
spec:
  dnsConfig:
    options:
      - name: ndots
        value: "2"
      - name: single-request-reopen
      - name: timeout
        value: "2"
      - name: attempts
        value: "2"
05
STAGE 05 · SYSTEM DESIGN APPLICATIONSL7 · STAFF / PRINCIPAL

Where NodeLocal DNS & ndots Tuning apply in Kubernetes.

Why this matters: Scope boundary: identify where this pattern fits best and where simpler or async alternatives win.

DNS amplification and conntrack tuning are essential for high-QPS Kubernetes platforms:

  • Payment & Webhook Egress Clusters: Services calling Stripe, AWS S3, or Twilio at 40,000+ req/s.
  • Multi-Tenant Microservice Meshes: Keeping internal redis-master short-name resolution working while protecting CoreDNS.
  • Linux Conntrack Hardening: Preventing UDP table exhaustion on high-density 120-node clusters.
Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

Why does Kubernetes' default ndots:5 setting flood CoreDNS with NXDOMAIN queries for external domains like api.stripe.com?

Recommended Learning Flow