Bitzu

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

Single choice

Which component is the default DNS server for service discovery in current Kubernetes clusters?

  1. etcd
  2. CoreDNS
  3. kube-proxy
  4. 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.

Select all that apply

Which of these names resolve to the Service cache in namespace data when queried from a Pod in namespace data?

  1. cache
  2. cache.data.svc.cluster.local
  3. cache.default
  4. data.cache
  5. 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

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.

Download on the App StoreGet it on Google Play

More KCNA topics in this module