The Service's selector matches no Pods
Endpoints: (empty) ENDPOINTS <unset> Connection refused
What you see
$ kubectl describe service orders -n shop
# (trimmed to the lines that matter)
Name: orders
Namespace: shop
Selector: app=orders,tier=backend
Type: ClusterIP
IP: 172.20.45.12
Port: http 80/TCP
TargetPort: 8080/TCP
Endpoints:
Session Affinity: None$ kubectl get endpointslices -n shop -l kubernetes.io/service-name=orders
NAME ADDRESSTYPE PORTS ENDPOINTS AGE
orders-5xq8k IPv4 <unset> <unset> 2dThe Endpoints: line lists only ready Pod IPs, and here it's empty (older kubectl prints <none>). The EndpointSlice's ENDPOINTS <unset> says more: no Pod matched at all, ready or not. With nothing to send to, kube-proxy rejects connections to the ClusterIP, so callers get refused at once.
Confirm
# The Service's selector
kubectl get service orders -n shop -o jsonpath='{.spec.selector}{"\n"}'
# Does any Pod match it? Use the selector exactly as printed
kubectl get pods -n shop -l app=orders,tier=backend
# Which labels do the Pods really have?
kubectl get pods -n shop --show-labelsNo resources found from the second command settles it. A selector is an AND: a Pod needs every key with the same value. It also only looks in the Service's own namespace.
Fix
- Labels were renamed (the Deployment moved to
app.kubernetes.io/name: orders, the Service still saysapp: orders): change the Service'sspec.selectorto labels the Pod template really has. Don't label running Pods by hand; their replacements won't have it. - An extra key (here
tier: backend, which the Pods don't carry): remove it from the selector, or add it to the Deployment'sspec.template.metadata.labels. - No Pods at all (scaled to 0, or every Pod is Pending): fix the workload first. A Pending Pod has no IP, so it can't be an endpoint; see the Pod stuck in Pending playbook.
Prevent
- Keep the Service and the Deployment in one chart or kustomization, with the selector and the Pod labels set from the same value.
- After each rollout, check that the Service has ready endpoints, or alert when one has none.