A Kubernetes administrator deploys a StatefulSet called mongo in the prod namespace. The application expects each replica to reach its peers using hostnames such as mongo-0.mongo.prod.svc.cluster.local. However, DNS queries currently return only a single virtual IP for the Service, so the replicas cannot locate one another directly. The existing Service manifest is:
Which single modification will convert this Service into a headless Service that returns the individual Pod IP addresses and bypasses kube-proxy load balancing?
Set sessionAffinity: ClientIP in the Service spec.
Change the Service type to NodePort.
Insert clusterIP: None under spec.
Add publishNotReadyAddresses: true to the Service spec.
Adding clusterIP: None creates a headless Service. When clusterIP is explicitly set to the string None, Kubernetes does not allocate the Service a virtual IP. Instead, the cluster DNS server returns an A/AAAA record for every Pod that matches the Service's selector, enabling hostnames such as mongo-0.mongo.prod.svc.cluster.local to resolve directly to the corresponding Pod's IP. The other options do not remove the virtual IP or supply per-Pod DNS records:
type: NodePort still allocates a ClusterIP and merely opens a high port on each node for external access.
publishNotReadyAddresses: true changes when endpoints are published but does not alter VIP behavior.
sessionAffinity: ClientIP enables client-IP-based stickiness yet still relies on the Service's single virtual IP.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is a headless Service in Kubernetes?
Open an interactive chat with Bash
How does `clusterIP: None` impact DNS resolution in Kubernetes?
Open an interactive chat with Bash
Why is a headless Service necessary for StatefulSets in Kubernetes?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Automation, Orchestration, and Scripting
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access