Access a Kubernetes Service running locally in Docker For Desktop?
That service will be available in your browser at http://localhost:8037
Note that the port 8037
corresponds to the port
property on the ServiceSpec
object.
If you are unable to reach the service at that URL, then it could be one of several things, including but not limited to:
- There is another
Service
in your cluster that has claimed that port. Either delete the otherService
, or change theport
property to an unclaimed port. - Your
Pod
is not running and ready. Checkkubectl get pods
.
For local development you might want to use the type NodePort
for the service (see https://kubernetes.io/docs/concepts/services-networking/service/#nodeport). This binds the given nodePort
, as the name says, to a port of your node (which should be localhost for docker-on-desktop).
Then the the service should be available ob http://localhost:31534.
Port forwarding:
kubectl port-forward <my-pod-name> 4000:8037
Your pod's internal port (8037) will be accessible on localhost:4000
.
Docs here.