Quick answer: to fix stale upstream nodes in a Kubernetes EndpointSlice discovery provider, first confirm that the stale backend is still being advertised, then compare the Service, matching Pods, and generated EndpointSlice objects. In most cases, the root cause is a selector mismatch, readiness state that does not match expectations, delayed watch or cache refresh, or a consumer that has not reloaded the latest slice data.
This guide stays focused on the failure pattern itself: an upstream consumer continues sending traffic to endpoints that should already have been removed or replaced. The useful work is to prove which object is stale, where that stale state is coming from, and whether the problem is in Kubernetes state or in the component consuming EndpointSlice data.
Applies To
Kubernetes clusters using EndpointSlice-based service discovery, especially when an ingress controller, gateway, proxy, or custom discovery provider builds upstream node lists from Service, Pod, and EndpointSlice state.
Symptoms
- Traffic is still routed to an old pod IP, node, or backend that should already be gone.
- A rollout, pod restart, node drain, or scaling event completes, but the upstream list does not match the current cluster state.
- The
Servicelooks correct, but requests still fail or land on a backend you did not expect. - Retries may appear to help because only part of the upstream set is stale.
Most Common Causes
- The
Serviceselector does not match the pods you think it matches. - Pod readiness or termination state does not line up with when the upstream consumer should add or remove endpoints.
- The generated
EndpointSliceobjects are correct, but the discovery provider is using a stale watch result or cache. - The discovery provider only refreshes upstream state on a delayed interval or after a separate reload path.
- You are inspecting one namespace, service, or cluster object while the consumer is actually reading another.
Step-by-Step Fix
1. Capture the stale upstream exactly
Write down the backend IP, node, service name, namespace, and the time window when you observed the stale route. Without that, it is easy to compare the wrong objects or miss a short-lived state change.
date
kubectl get svc -A
kubectl get pods -A -o wide
kubectl get endpointslice -A
2. Compare Service, Pods, and EndpointSlice state
Start from the affected Service. Check its selector, then list the matching pods and the generated EndpointSlice entries. The first question is simple: does Kubernetes still advertise the stale backend, or is the stale state only inside the consumer?
kubectl get svc <service> -n <namespace> -o yaml
kubectl get pods -n <namespace> -l app=<label> -o wide
kubectl get endpointslice -n <namespace> -l kubernetes.io/service-name=<service> -o yaml
3. Verify readiness and termination behavior
If the stale backend appears in the slice, inspect pod readiness, deletion timestamps, and whether the pod is still terminating. A backend that looks gone at the application layer may still be present in cluster state long enough to be advertised.
4. Inspect the discovery provider log and cache path
If the EndpointSlice objects are already correct, move to the component that consumes them. Check the nearest log first and confirm whether it saw the watch event, processed the update, and rebuilt its upstream list. This is where stale informer caches, dropped watch events, or delayed reload logic usually show up.
5. Check that you are looking at the right runtime target
Many troubleshooting sessions go sideways because the operator inspects the wrong namespace, the wrong service name, or the wrong controller instance. Confirm the exact runtime target before changing anything.
6. Apply one small change, then verify
After you identify the mismatch, make the smallest fix that matches the evidence: correct the selector, resolve readiness behavior, remove the stale pod, or force the consumer to pick up the latest EndpointSlice state only after you have captured the logs you need.
Verification
- Confirm the stale backend no longer appears in the relevant
EndpointSliceoutput. - Check the discovery provider log and verify that the latest update was observed and applied.
- Run the original request path again and confirm traffic no longer reaches the old upstream node.
- Watch the next rollout, restart, or scale event to make sure the upstream list changes when cluster state changes.
Production Notes
Do not start by restarting every controller. In this class of problem, a restart may clear the symptom while hiding whether the stale state came from Kubernetes objects, a watch path, or a local cache. Capture the current objects and logs first, then make a single targeted change with a rollback path.
FAQ
How do I tell whether Kubernetes or the consumer is stale?
Compare the current EndpointSlice objects with the actual upstream list in the consumer. If the slice still contains the old backend, the stale state is still in Kubernetes object data. If the slice is already correct but traffic still goes to the old backend, the stale state is in the consumer path.
Should I restart the discovery provider first?
Only after you capture the relevant logs and object state. A restart may temporarily refresh the upstream list, but it does not tell you why the state became stale in the first place.
What usually fixes this fastest?
The fastest reliable fix is the one that matches the evidence. In practice that usually means correcting the service-to-pod mapping, resolving readiness or termination timing, or forcing the consumer to reload after confirming that the EndpointSlice data is already correct.