KCNA ยท Kubernetes networking
Cluster DNS and service discovery
CoreDNS, service DNS names, namespaces in names, Pod DNS policy basics.
Key points
- CoreDNS is the cluster DNS server.
- A Service gets the name <service>.<namespace>.svc.<cluster-domain> (cluster.local by default).
- Pods get an /etc/resolv.conf pointing at cluster DNS with search domains, so inside the same namespace the short name works, while another namespace needs <service>.<namespace>.
- The Pod dnsPolicy defaults to ClusterFirst.
Source: https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/
Practice questions
Which component is the default DNS server for service discovery in current Kubernetes clusters?
- etcd
- CoreDNS
- kube-proxy
- The kubelet
Show answer
Answer: B. CoreDNS
CoreDNS runs as a Deployment in kube-system and answers cluster DNS queries. etcd stores state, kubelet runs Pods and kube-proxy programs Service rules.
Which of these names resolve to the Service cache in namespace data when queried from a Pod in namespace data?
- cache
- cache.data.svc.cluster.local
- cache.default
- data.cache
- cache.svc.data
Show answer
Answer: A. cache, B. cache.data.svc.cluster.local
Search domains let the short name and the namespace-qualified name work, and the full name always does. cache.default names a different namespace, and data.cache reverses the order.
True or false: A Pod with no dnsPolicy set uses the node's own DNS settings, because the default policy is named Default.
Show answer
Answer: False
False. The policy named Default means inherit from the node, but it is not the default; when unset, ClusterFirst applies.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
