Certified Kubernetes Application Developer (CKAD) Practice Test

Disable ads (and more) with a membership for a one time $2.99 payment

Question: 1 / 50

How can you create a headless service in Kubernetes?

By setting the cluster IP address to none in the service definition

To create a headless service in Kubernetes, you set the cluster IP address to "None" in the service definition. This approach allows Kubernetes to bypass the standard load-balancing feature typically associated with services. When the cluster IP is set to "None," instead of having a single IP address to route traffic to, the service will return the individual pod IPs directly. This is particularly useful for scenarios such as stateful applications, where you might need direct access to each pod for communication or discovery purposes. Utilizing "None" for the cluster IP informs Kubernetes not to allocate a virtual IP for the service. As a result, all DNS queries against the service return a list of the IPs corresponding to the pods backing that service, allowing clients to connect directly to the endpoints. Other methods, like specifying high availability settings, using NodePort, or defining unique selectors, do not provide the functionality of a headless service, as they either involve load balancing, external accessibility mechanism, or simply differentiate between pods based on selectors without altering the service's IP behavior.

By specifying high availability settings in the service config

By using the NodePort feature for external access

By defining a unique selector for the service

Next

Report this question