Networking
medium

Questão de Networking #019e3a4f

Enunciado da Questão
Networking
#kubernetes
#dns
#service-discovery
#kube-dns
#coredns
Médio

What is the main role of the Kubernetes DNS within a cluster?

A

Acts as a DNS server for virtual machines that are running outside the cluster.

B

Provides a DNS as a Service, allowing users to create zones and registries for domains that they own.

C

Allows Pods running in dual stack to convert IPv6 calls into IPv4 calls.

D

Provides consistent DNS Names for Pods and Services for workloads that need to communicate with each other.

Correta

Explicação Oficial / Explicações da Comunidade

The main role of Kubernetes DNS is to provide consistent DNS names for Pods and Services, enabling reliable service discovery and communication within the cluster. Kubernetes DNS (typically implemented by CoreDNS or kube-dns) automatically assigns DNS records to Services and Pods. For example, a Service named my-service in the namespace my-ns is resolvable as my-service.my-ns.svc.cluster.local. Pods also get DNS names based on their hostname and subdomain. This eliminates the need for hard-coded IP addresses and allows workloads to find each other dynamically.

How it Works:

  • The DNS add-on runs as a set of Pods in the cluster, usually in the kube-system namespace.
  • It watches the Kubernetes API for new Services and Endpoints, and updates its DNS records accordingly.
  • Pods are configured to use the cluster DNS server via the dnsPolicy field in their Pod spec (default is ClusterFirst), which modifies the Pod's /etc/resolv.conf to point to the cluster DNS IP.
  • The DNS server resolves Service names to ClusterIPs (or headless Service endpoints) and Pod names to Pod IPs.

Why the correct answer is right:
The statement "Provides consistent DNS Names for Pods and Services for workloads that need to communicate with each other" accurately describes the primary function of Kubernetes DNS. It ensures that Pods and Services have stable, predictable DNS names that remain consistent even if the underlying IP addresses change.

Why the incorrect options are wrong:

  • "Acts as a DNS server for virtual machines that are running outside the cluster" is incorrect because Kubernetes DNS is internal to the cluster and does not serve external VMs. External DNS resolution is handled by other mechanisms like ExternalDNS or manual DNS configuration.
  • "Provides a DNS as a Service, allowing users to create zones and registries for domains that they own" is incorrect because Kubernetes DNS does not expose a user-facing DNS management interface for creating custom zones. It automatically manages DNS records for cluster resources only.
  • "Allows Pods running in dual stack to convert IPv6 calls into IPv4 calls" is incorrect because Kubernetes DNS does not perform protocol conversion. Dual-stack support allows Pods to use both IPv4 and IPv6 addresses, but DNS resolution remains separate; the DNS server can return A (IPv4) and AAAA (IPv6) records as appropriate.