Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

Kubernetes: Service has no endpoints

An empty Endpoints list means the selector or port names do not match a ready pod. Compare labels, check targetPort, and confirm readiness probes pass.

~5 min readKubernetes
#kubernetes#services#networking#troubleshooting
Kubernetes service rail with an empty endpoint plate and a pod crate labeled differently

Introduction & Quick Summary

A Service exists, pods are running, and the address refuses connections:

code
$ kubectl get endpoints web NAME ENDPOINTS AGE web <none> 14m $ kubectl describe svc web Selector: app=web-frontend Port: http 80/TCP TargetPort: http/TCP Endpoints: <none>

Quick answer: a Service forwards traffic only to pods that match its selector and are Ready, on a port the pod actually exposes. With <none> endpoints there is no backend to route to, so the virtual IP drops or refuses every request.

Work the four checks in order:

bash
kubectl get svc web -o jsonpath='{.spec.selector}{"\n"}' kubectl get pods -n default -l app=web-frontend -o wide kubectl get endpointslice -l kubernetes.io/service-name=web -o wide kubectl get pod <pod> -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}{"\n"}'

Whichever command comes back empty or False is the broken link. In practice the order is: no pod matches the selector, pods match but are not Ready, or the pod is Ready but the port name does not resolve.

This guide explains how a Service gets its endpoints, the five conditions a pod must satisfy to appear in an EndpointSlice, and the debugging sequence that finds the broken link in one pass instead of guessing.

Core Mechanics, Signatures & Reproducible Setup

A ClusterIP Service is not a process. It is a virtual address programmed into each node's packet filter, and the rules are generated from EndpointSlice objects that controllers maintain. kube-proxy (or the CNI's eBPF replacement) watches slices and rewrites traffic for ClusterIP:port to one of the listed pod IPs.

An EndpointSlice contains an entry for a pod only when all of these hold:

  1. The pod's labels match every key and value in spec.selector.
  2. The pod is in the same namespace as the Service.
  3. The pod has an IP address and is not terminated.
  4. The pod is Ready, unless the Service sets publishNotReadyAddresses: true.
  5. For a named targetPort, the pod declares a container port with that name.

A minimal working pair:

apiVersion: v1 kind: Service metadata: name: web spec: selector: app: web-frontend # must match the pod label exactly ports: - name: http port: 80 # what clients call targetPort: http # container port name, or a number --- apiVersion: apps/v1 kind: Deployment metadata: name: web spec: selector: matchLabels: { app: web-frontend } template: metadata: labels: { app: web-frontend } spec: containers: - name: web image: nginx:1.27-alpine ports: - name: http containerPort: 80 readinessProbe: httpGet: { path: /, port: http }

Reproduce the empty-endpoint state by changing one label:

bash
kubectl apply -f web.yaml kubectl get endpoints web # 10.244.x.x:80 kubectl patch svc web -p '{"spec":{"selector":{"app":"web"}}}' kubectl get endpoints web # <none> kubectl describe endpointslice -l kubernetes.io/service-name=web

The slice controller does not guess. A selector that matches nothing produces an empty slice and no warning, and the Service keeps its ClusterIP.

Key Comparison Table

CheckCommandHealthy result
Selector matches podskubectl get pods -l app=web-frontendat least one Running pod
Pod is Readykubectl get pod -o wide / describeREADY 1/1
EndpointSlice existskubectl get endpointslice -l kubernetes.io/service-name=webone or more addresses
Named port resolveskubectl get pod -o jsonpath='{.spec.containers[*].ports}'port named http
DNS resolveskubectl run tmp --rm -it --image=busybox -- nslookup webthe ClusterIP
SymptomCauseFix
<none> endpoints, pods runninglabel typo or different namespacecorrect the selector or the pod label
<none> endpoints, pods 0/1readiness probe failingfix the probe path, port or timing
Endpoints listed, connection refusedtargetPort points at a closed portalign container port and app listen address
Endpoints listed, timeoutNetworkPolicy or wrong Service portallow the traffic, check port
Works in one namespace onlyService selector is namespace-scopeddeploy the Service beside the pods
Service kindGets endpoints fromNotes
ClusterIP with selectorEndpointSlice controllerthe default case
Headless (clusterIP: None)same controller, per-pod DNSclients resolve pod IPs directly
ExternalNamenoneCNAME only, no proxying
No selectormanual EndpointSliceyou own the addresses

Practical Edge Cases, Error Fixes & Deep Dive Code Examples

1. Selector typos and namespace drift

app: web-frontend does not match app: web or app.kubernetes.io/name: web-frontend. Compare the two objects directly instead of reading YAML by eye:

bash
kubectl get svc web -o jsonpath='{.metadata.namespace} {.spec.selector}{"\n"}' kubectl get pods -A -l app=web-frontend --show-labels

-A is the important flag: a Service in default cannot select pods in staging, and the two namespaces often hold identical Deployments during a migration.

2. Readiness probes keep a pod out of the slice

A Running pod with 0/1 Ready contributes no endpoint. describe pod shows the probe error, and the events show repeated Readiness probe failed:

readinessProbe: httpGet: { path: /healthz, port: 8080 } initialDelaySeconds: 5 periodSeconds: 5 failureThreshold: 3

Use a path that does not depend on the database if the goal is only "process is up"; otherwise a database blip removes every endpoint at once and the Service goes from healthy to <none> during an unrelated incident. publishNotReadyAddresses: true is the deliberate exception, and it is right mainly for peer-discovery Services such as a database cluster's headless entry.

3. targetPort and named ports

A numeric targetPort that no container listens on yields endpoints but refused connections, because the pod IP is routable and nothing is bound:

ports: - port: 80 targetPort: 8080 # container must listen on 8080, not 80

For named ports, the name must exist in the pod spec, be unique per pod, and stay within 15 characters:

# Service targetPort: http # Pod ports: [{ name: http, containerPort: 8080 }]

A pod that listens on 127.0.0.1:8080 also produces this symptom: the IP is reachable but the socket is bound to loopback only. Bind to 0.0.0.0 inside containers.

4. Endpoints, EndpointSlices, and where to look

kubectl get endpoints still works but mirrors a deprecated API. The controller writes EndpointSlices, and each carries the readiness and topology data:

bash
kubectl get endpointslice -l kubernetes.io/service-name=web -o yaml | \ grep -E 'addresses|ready|conditions|ports' -A2

If slices list addresses but traffic still fails, the problem has moved past service discovery: check kube-proxy logs on the node, NetworkPolicy, and whether the client is in a namespace with an egress policy.

bash
kubectl -n kube-system logs -l k8s-app=kube-proxy --tail=50 kubectl run tmp --rm -it --image=nicolaka/netshoot -- curl -sv http://web.default.svc.cluster.local

5. Services without selectors

Batch jobs, external databases and migration targets often use a Service with no selector and a hand-written slice. Nothing populates it automatically, so it stays empty until you write one:

apiVersion: discovery.k8s.io/v1 kind: EndpointSlice metadata: name: legacy-db-1 labels: { kubernetes.io/service-name: legacy-db } addressType: IPv4 ports: [{ name: postgres, port: 5432 }] endpoints: - addresses: ["10.0.5.20"] conditions: { ready: true }

Once the slice exists, kubectl get endpoints legacy-db shows the address, and a wrong port here produces a connection refused that looks like a Service bug.

6. Headless services and per-pod DNS

With clusterIP: None there is no virtual IP, and clients resolve web.default.svc.cluster.local to the pod IPs directly. A StatefulSet's stable names (web-0.web.default.svc.cluster.local) require publishNotReadyAddresses for bootstrap, because a peer that is not Ready still needs to be discoverable while the cluster forms.

The curl tool documents how to reproduce the exact request from inside a pod, including the -v and --resolve flags that separate DNS from routing, and the JSON formatter makes a long -o json dump of a Service readable.

Common Compilation/Runtime Mistakes & Version Gotchas

  • Reading only kubectl get pods. Running is not Ready; the endpoint decision uses the Ready condition.
  • Changing the Service instead of the selector owner. Editing a Service's selector to match a typo fixes one object and leaves the Deployment inconsistent.
  • Expecting a Service to load-balance to pods in another namespace. Selectors do not cross namespaces.
  • Using port where targetPort belongs. port is what clients call; targetPort is where the container listens.
  • Ignoring dual-stack. A single-stack Service in a dual-stack cluster gets one family of endpoints; a client on the other family sees timeouts.
  • Kubernetes 1.33 and later. The Endpoints API is deprecated in favour of EndpointSlices; tooling that reads /api/v1/endpoints may lag behind the actual routing state.
  • Assuming NetworkPolicy is the culprit first. With <none> endpoints, policy never comes into play; fix discovery before debugging packet filters.

Official documentation: Service and endpoint semantics and Debugging Services.

Official references

primary documentation

The Kubernetes documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit Kubernetes work — they run entirely in this browser tab, so nothing you paste leaves your device.

All Kubernetes guides

More in Kubernetes

All Kubernetes guides

The guides filed next to this one in Kubernetes, in library order.