No endpoints available for service

One of the most subtle issues to hunt down is why isn't my service acting as I expect? A common error to see in these cases is this message:

no endpoints available for service

If you have created a deployment and a service together, and everything seems to be running, but when you access the service endpoint you see this output:

{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {
    
  },
  "status": "Failure",
  "message": "no endpoints available for service \"flask-service\"",
  "reason": "ServiceUnavailable",
  "code": 503
}

In this case, I received this message when using kubectl proxy to access the service endpoint flask-service through the proxy using the URL:

http://localhost:8001/api/v1/proxy/namespaces/default/services/flask-service ...

Get Kubernetes for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.