Interview Prep/Kubernetes/Services, DNS, Ingress and NetworkPolicy

The cluster DNS works, but CoreDNS CPU is pegged and logs show thousands of queries per second for names like `metadata.google.internal.svc.cluster.local`.

IntermediateTroubleshootingServices, DNS, Ingress and NetworkPolicy
Answer

Likely causes → A chatty client (SDK probing a metadata endpoint, a service resolving on every request without caching) multiplied by ndots:5 search expansion; CoreDNS has too few replicas and cache is small.

Diagnose →

kubectl -n kube-system edit configmap coredns     # add 'log' temporarily
kubectl logs -n kube-system -l k8s-app=kube-dns | awk '{print $NF}' | sort | uniq -c | sort -rn | head
kubectl top pods -n kube-system -l k8s-app=kube-dns

Fix → Find the client and fix its caching or name; scale CoreDNS (cluster-proportional-autoscaler), raise cache 30, deploy NodeLocal DNSCache. Remove the log plugin afterwards.

Prevent → Monitor coredns_dns_requests_total by type and response code; NXDOMAIN rates reveal ndots abuse.

All Kubernetes questions Roadmap: Kubernetes networking, storage & scaling

More on Services, DNS, Ingress and NetworkPolicy