You run 'kubectl get svc my-service -o yaml' and see 'type: ClusterIP'. The service has no endpoints. What is the most likely cause?
Trap 1: The service type is ClusterIP, which does not support endpoints.
ClusterIP is the default Service type and it fully supports endpoints. Kubernetes automatically creates an Endpoints object (or EndpointSlices) for any ClusterIP Service that has a selector, using the IPs of matching pods. A missing endpoint list is never caused by the Service type itself; an Endpoints object may be empty because no pods match the selector, not because ClusterIP lacks endpoint capability.
Trap 2: The service's port does not match the container port.
A service port and container port mismatch prevents traffic from getting through, but it does not affect whether endpoints are created. When a Service has a selector, the endpoint controller writes each matching pod's IP and the targetPort (filling in the default if omitted) into the Endpoints object, regardless of the Service's own port number. If the port were the issue, you would still see endpoints listed but connectivity would fail; no endpoints at all points squarely to a selector or readiness problem.
Trap 3: The service is misconfigured and needs to be deleted and recreated.
Deleting and recreating a Service does not change the fact that endpoints are generated from pod label selectors, not from the Service object's existence. If no pods match the selector or the matching pods are not Ready, the new Service will also have an empty Endpoints list. This option incorrectly assumes a malformed spec is to blame when in practice the most common reason for missing endpoints is absent or unready pods, not a need for recreation.
- A
The service type is ClusterIP, which does not support endpoints.
Why wrong: ClusterIP is the default Service type and it fully supports endpoints. Kubernetes automatically creates an Endpoints object (or EndpointSlices) for any ClusterIP Service that has a selector, using the IPs of matching pods. A missing endpoint list is never caused by the Service type itself; an Endpoints object may be empty because no pods match the selector, not because ClusterIP lacks endpoint capability.
- B
The service's port does not match the container port.
Why wrong: A service port and container port mismatch prevents traffic from getting through, but it does not affect whether endpoints are created. When a Service has a selector, the endpoint controller writes each matching pod's IP and the targetPort (filling in the default if omitted) into the Endpoints object, regardless of the Service's own port number. If the port were the issue, you would still see endpoints listed but connectivity would fail; no endpoints at all points squarely to a selector or readiness problem.
- C
The service is misconfigured and needs to be deleted and recreated.
Why wrong: Deleting and recreating a Service does not change the fact that endpoints are generated from pod label selectors, not from the Service object's existence. If no pods match the selector or the matching pods are not Ready, the new Service will also have an empty Endpoints list. This option incorrectly assumes a malformed spec is to blame when in practice the most common reason for missing endpoints is absent or unready pods, not a need for recreation.
- D
No pods with labels matching the service selector are running and ready.
The endpoint controller only publishes Backends for pods that match the Service's selector and have their Ready condition set to True. If no pod carries the label/value pair defined in the selector, or if all matching pods are still Pending/Running with failing readiness probes, the Endpoints object stays empty. This is the canonical root cause of a Service with type ClusterIP but no endpoints.