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:5instructs 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):- Queries:
api.stripe.com.mynamespace.svc.cluster.local(NXDOMAIN) - Queries:
api.stripe.com.svc.cluster.local(NXDOMAIN) - Queries:
api.stripe.com.cluster.local(NXDOMAIN) - Finally queries:
api.stripe.com.
- Queries:
- 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 setdnsConfig: { options: [{ name: "ndots", value: "2" }] }.