Cannot curl Kubernetes service IP from the host

6/11/2018

I am having the same problem as mentioned here: Cannot access kubernetes service via outside network. I have tried the solution mentioned using Ingress, but without any success.

My pods are up and running, along with my service.

I can curl any of the endpoints successfully from within a pod, but not able to curl from the host.

When I am using Ingress, the address field shows blank, and while trying to curl the hostname, it shows Could not resolve host.

I am using Kubernetes on Docker Edge, on a MacBook Pro.

How do I curl the service endpoint from the host?

-- Dipankar Ghosh
curl
docker
kubernetes
kubernetes-ingress

1 Answer

6/11/2018

First of all, please note that Kubernetes on MacOS runs separate virtual machine to run Docker containers and Kubernetes as well. It is important to understand that you can have a problem connecting from MacOS to some Kubernetes resources. TCP connections are not realized in the same way they are in the cloud environment. It depends on the configuration of the internetworking between MacOS and the VM where Kubernetes stack is running. (NAT, bridge, host only connection)

I suppose that you chose a NodePort Service and in this kind of configuration, you need to know both: the IP address of a node and the port where Kubernetes started to listen to the incoming connection. Ingress, in this case, analyses a host http header to determine a route of the traffic. It’s similar to the Service created on type:NodePort. You need to call a proper Ingress service. It is not obvious that service is listening on Well-Known Port. In fact, It is a bit tricky, and it may not be easy to connect from MacOS to type:NodePort service without knowing where did Kubernetes create a listening socket, and be sure that MacOS is actually supporting routes to this TCP port from MacOS to VM.

-- d0bry
Source: StackOverflow