Interview Prep/Kubernetes/Services, Networking, Ingress & Gateway API

How does DNS work inside a cluster?

BeginnerConceptServices, Networking, Ingress & Gateway API
Answer

CoreDNS runs as a Deployment in kube-system and serves the cluster.local zone. A Service web in namespace shop resolves as web.shop.svc.cluster.local; within the same namespace plain web works thanks to the search list in the Pod's /etc/resolv.conf. Pods get ndots:5 by default.

kubectl exec -it deploy/web -- cat /etc/resolv.conf
kubectl run -it --rm dnsutils --image=registry.k8s.io/e2e-test-images/agnhost:2.47 -- nslookup kubernetes.default
All Kubernetes questions Roadmap: Kubernetes networking, storage & scaling

More on Services, Networking, Ingress & Gateway API