Service Configuration
medium

Pregunta de Service Configuration #019e3a4f

Enunciado de la Pregunta
Service Configuration
#kubernetes
#services
#endpoints
#selectors
Medio

Which type of Service requires manual creation of Endpoints?

A

LoadBalancer

B

Services without selectors

Correcto
C

NodePort

D

ClusterIP with selectors

Explicación Oficial / Explicaciones de la Comunidad

In Kubernetes, a Service without a selector requires manual creation of Endpoints. This is because the Service does not automatically discover Pods based on labels; instead, you must explicitly define the Endpoints object that maps the Service to a set of IP addresses and ports. This is useful for integrating external resources or services that are not managed by Kubernetes.

How it Works

A Kubernetes Service typically uses a label selector to identify Pods that should receive traffic. When a selector is defined, the control plane automatically creates and updates an Endpoints object that lists the IP addresses of the matching Pods. However, when a Service is created without a selector (i.e., the spec.selector field is omitted), no Endpoints are automatically generated. You must manually create an Endpoints resource with the same name as the Service, specifying the target IP addresses and ports. The Service then routes traffic to those endpoints.

Why the Correct Answer is Right

Services without selectors are the only type that requires manual Endpoints creation. This is explicitly documented in Kubernetes: "Services that do not have selectors are not automatically associated with any Endpoints. You must manually create an Endpoints object to map the Service to the network address and port where it is running."

Why the Incorrect Answers are Wrong

  • LoadBalancer: A LoadBalancer Service typically uses a selector to identify Pods. The cloud provider provisions a load balancer that forwards traffic to the Service's endpoints, which are automatically managed based on the selector.
  • NodePort: A NodePort Service exposes the Service on each Node's IP at a static port. It still requires a selector to identify the target Pods; endpoints are automatically created.
  • ClusterIP with selectors: This is the default Service type. When a selector is defined, endpoints are automatically created and updated by the control plane. No manual intervention is needed.

In summary, only Services without selectors necessitate manual Endpoints creation, as there is no automatic discovery mechanism.