DevOps · Flashcard

A developer creates a Service targeting Pods with label 'app: backend', but the Service returns no endpoints. Running 'kubectl get endpoints my-service' shows an empty list. The Pods are running and healthy. What is the most likely cause?

  • AThe Service selector doesn't match the Pods' labels — either the label key/value is misspelled or the Pods use a different label (e.g., 'app: back-end' vs 'app: backend'). Label selectors require exact string matches with no fuzzy matching
  • BThe Service is in a different namespace than the Pods, and Services can only route to Pods in different namespaces if the Pods have the annotation 'service.kubernetes.io/cross-namespace: true'
  • CThe Pods are running but not yet in Ready state, and Services only include Pods that have been running for at least 30 seconds to avoid routing to containers that are still initializing
  • DThe kube-proxy hasn't synced the new Service yet — after creating a Service, there is a mandatory 5-minute propagation delay before endpoints are populated

Why this is the answer

The most common cause of empty endpoints is a label selector mismatch. The Service's spec.selector must exactly match the labels on the target Pods. Even a subtle difference (dash vs underscore, different capitalization) causes a complete mismatch. Debug with 'kubectl get pods --show-labels' and compare against 'kubectl get svc -o yaml'. Services do require Pods to be Ready, but this wouldn't result in zero endpoints unless all Pods are unready.

Official docs
Study in Gnoseed →