In Kubernetes, how does the DNS service discovery mechanism help pods find other services?
Think about how pods avoid using fixed IPs and still find services dynamically.
Kubernetes creates DNS entries for services that resolve to their cluster IPs. Pods use these DNS names to communicate without needing fixed IPs.
What is the output of the following command run inside a pod in Kubernetes?
nslookup my-service.default.svc.cluster.local
Consider the default cluster IP range and DNS naming conventions.
The DNS name resolves to the cluster IP of the service, typically in the 10.96.0.0/12 range by default.
Which YAML snippet correctly defines a headless service to enable DNS-based service discovery of individual pods?
Headless services have no cluster IP to allow direct pod DNS entries.
Setting clusterIP to None creates a headless service, enabling DNS to return pod IPs directly for service discovery.
A pod cannot resolve the DNS name of a service inside the cluster. Which is the most likely cause?
DNS resolution depends on a running DNS server inside the cluster.
If CoreDNS pods are down, DNS queries inside the cluster fail, causing resolution errors.
Put these steps in the correct order to verify DNS-based service discovery inside a Kubernetes cluster.
Start by checking cluster components, then run tests inside pods.
First verify the service exists, then confirm DNS server health, next run a pod with DNS tools, and finally query the service DNS name.