Requests to a Service sometimes hit a Pod that was deleted seconds ago, causing errors during every rollout.
AdvancedTroubleshootingServices, DNS, Ingress and NetworkPolicy
Answer
Likely causes → Endpoint removal is asynchronous. When a Pod gets deletion, kubelet sends SIGTERM while kube-proxy on every node, ingress controllers and cloud LBs are still removing it from their backends. An app that stops listening immediately receives traffic for a few more seconds.
Diagnose →
kubectl get events --field-selector reason=Killing -n web --watch &
kubectl logs -n ingress-nginx deploy/ingress-nginx-controller -f | grep -E ' 50[23] '
Fix → Delay shutdown so endpoint removal propagates first, then drain:
lifecycle:
preStop:
sleep: {seconds: 10}
terminationGracePeriodSeconds: 45
The app should keep serving in-flight requests after SIGTERM and stop accepting new ones gracefully.
Prevent → Standard preStop in base charts; with AWS LB Controller, also tune target group deregistration_delay and use Pod readiness gates.
More on Services, DNS, Ingress and NetworkPolicy
`curl http://orders.shop.svc.cluster.local` hangs, and `kubectl get endpointslices -l kubernetes.io/service-name=orders` shows `ENDPOINTS <unset>`.BeginnerEndpoints exist, but `curl orders:80` returns `Connection refused`.BeginnerA Service works when you curl the Pod IP but times out on the ClusterIP from every node.IntermediateInside a Pod, `nslookup orders` returns `;; connection timed out; no servers could be reached`.BeginnerCoreDNS Pods are in CrashLoopBackOff with `[FATAL] plugin/loop: Loop (127.0.0.1:41823 -> :53) detected for zone "."`.IntermediateCalls to `api.stripe.com` from Pods are slow, and CoreDNS logs show `api.stripe.com.payments.svc.cluster.local`, `api.stripe.com.svc.cluster.local` … all `NXDOMAIN`.Intermediate