Minikube: windows minikube service port not exposed

Created on 31 Mar 2019  路  8Comments  路  Source: kubernetes/minikube

I created a service and pod in minikube. Tested the application in Pod (shell) using curl command.
Service is up and running.
Service command:
kubectl.exe expose deployment hello-node --type=NodePort

list services
kubectl.exe get svc hello-node

_Result:_
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-node NodePort 10.109.254.5 80:30830/TCP 20m

url listing:
minikube.exe service --url hello-node

_result_
http://192.168.99.101:30830

But I could not execute the url which states connection refused.

Could you please advise how to call the api inside pod via the service port.

cservice triagduplicate

Most helpful comment

Not sure this was the same issue as the marked dupe 3587 which talks about minikube service not responding, which seems like a different issue.

But I did find something interesting. When I run "minikube service hello-node" I get this output:

| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|------------|-------------|-------------------------|
| default | hello-node | 8080 | http://172.17.0.4:31848 |

And when I log into the kubernetes docker container with docker exec -it 6fea2a81ca60 /bin/bash then type curl http://172.17.0.4:31848 I do indeed get back "Hello world!". So hello world service is indeed running, it's just not accessible from outside the docker container. I'm on Windows and Docker uses Hyper-V, so I'm wondering if this has more to do with how Hyper-V is isolating itself from my Windows host machine, maybe need to play with "Virtual Switches" and so on to get the service truly exposed to the host machine...

All 8 comments

I have the same problem with macOS.
I followed the instructions on https://kubernetes.io/docs/tutorials/hello-minikube/.

$ kubectl config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority: /Users/afberendsen/.minikube/ca.crt
    server: https://192.168.99.102:8443
  name: minikube
contexts:
- context:
    cluster: minikube
    user: minikube
  name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
  user:
    client-certificate: /Users/afberendsen/.minikube/client.crt
    client-key: /Users/afberendsen/.minikube/client.key
$ kubectl expose deployment hello-node --type=LoadBalancer --port=8080
service "hello-node" exposed
$ kubectl get services
NAME         TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
hello-node   LoadBalancer   10.111.32.14   <pending>     8080:31815/TCP   13s
kubernetes   ClusterIP      10.96.0.1      <none>        443/TCP          9m
$ curl 192.168.99.102:31815
curl: (7) Failed to connect to 192.168.99.102 port 31815: Connection refused

is the hello-node under services is running (green icon) ? if I use the node type as 'load-balancer' then service is not running but if you the change the node type as 'NodePort' then service is up and running.

But still could not access the exposed url.

I have the same problem with macOS.the service port not exposed

  • in macos
waynewyang:mysql waynewyang$ kubectl get pod
NAME                            READY   STATUS    RESTARTS   AGE
php-mysql-68986f5c5c-ffg2m      1/1     Running   2          166m
stretch-demo-5bdbbcdcf8-dm7f5   1/1     Running   0          4m37s
waynewyang:mysql waynewyang$ kubectl get service
NAME           TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
kubernetes     ClusterIP   10.96.0.1       <none>        443/TCP          3d
php-mysql      NodePort    10.98.247.152   <none>        3306:30001/TCP   15m
stretch-demo   NodePort    10.108.75.177   <none>        8080:32374/TCP   69s
  • in minikube
$ netstat -an | grep 30001
$ netstat -an | grep 32374

Closing in favor of #3587 as a dupe

Not sure this was the same issue as the marked dupe 3587 which talks about minikube service not responding, which seems like a different issue.

But I did find something interesting. When I run "minikube service hello-node" I get this output:

| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|------------|-------------|-------------------------|
| default | hello-node | 8080 | http://172.17.0.4:31848 |

And when I log into the kubernetes docker container with docker exec -it 6fea2a81ca60 /bin/bash then type curl http://172.17.0.4:31848 I do indeed get back "Hello world!". So hello world service is indeed running, it's just not accessible from outside the docker container. I'm on Windows and Docker uses Hyper-V, so I'm wondering if this has more to do with how Hyper-V is isolating itself from my Windows host machine, maybe need to play with "Virtual Switches" and so on to get the service truly exposed to the host machine...

@lovettchris I'm getting the same results, if you find a solution please share it with us, same goes for me.

@lovettchris Running into the same issue. It seems to be exclusive to the Docker driver, as switching to Hyper-V works. Maybe it's worth opening a separate issue?

EDIT: I created the ticket https://github.com/kubernetes/minikube/issues/7644

Maybe kubectrl proxy is the answer, Scott's blog works and the exposed .net core asp.net service runs fine and is accessible from my host machine.

Was this page helpful?
0 / 5 - 0 ratings