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
More on Services, Networking, Ingress & Gateway API
What is a Kubernetes Service and why do we need one?BeginnerWhat are the Service types?BeginnerWhat is the difference between `port`, `targetPort` and `nodePort`?BeginnerWhat is a headless Service and when do we use it?BeginnerWhat is an Ingress?BeginnerWhat is the difference between Ingress and Service type LoadBalancer?Beginner