Skip to main content
InterviewHubPRO
Section Overview
Q29

Question 29 of 50

Part 3: Advanced Internals, Scale & Production Security (Senior / Lead)

58%
Kubernetes (K8s) (50 Qs)•Part 3: Advanced Internals, Scale & Production Security (Senior / Lead)

Deep Dive: CoreDNS Performance, `ndots:5`, and DNS Latency Spikes.

senior LevelCode ExampleFormsPerformanceSecurity & Auth

In Simple Words: By default, the Linux /etc/resolv.conf injected by Kubelet into every Pod contains:

text
nameserver 10.96.0.10
search mynamespace.svc.cluster.local svc.cluster.local cluster.local
options ndots:5
  • The Problem: ndots:5 instructs the resolver: if a domain has fewer than 5 dots, append the search domains first before querying public DNS!
  • When your app queries api.stripe.com (2 dots):
    1. Queries: api.stripe.com.mynamespace.svc.cluster.local (NXDOMAIN)
    2. Queries: api.stripe.com.svc.cluster.local (NXDOMAIN)
    3. Queries: api.stripe.com.cluster.local (NXDOMAIN)
    4. Finally queries: api.stripe.com.
  • Result: CoreDNS is hammered with 4 DNS queries per external call!
  • Fix: Append a trailing dot to external URLs (api.stripe.com.), or configure NodeLocal DNSCache, or set dnsConfig: { options: [{ name: "ndots", value: "2" }] }.