I am running kubernetes single node on coreos.
I have created a pod running a python application and exposing an http endpoint.
I have created a kubernetes service that exposes the HTTP endpoint. I have exposed this service using NodePort and can call it successfully from outside the cluster.
What I am then trying is to call the HTTP service from a docker container. To test I am just using the same running container and using curl.
I can docker exec
into the docker container running my service. nslookup for 'my-service' resolves to an IP address. So I am happy that DNS service registration is working correctly. (I have also checked that the ENV variables for the service exist - and they do and are the same as the value returned from nslookup
)
However, if I then try:
curl http://my-service:9042/status
It just hangs with no response. (Port 9042 is the correct port and status is a valid resource)
I'm assuming that I'm missing something really obvious. Any suggestions warmly received.
Update:
The response of curl -v is:
root@lake-cluster-manager:/# curl -v http://lake-service:9042/status
* Hostname was NOT found in DNS cache
* Trying 10.3.0.128...
The output from nslookup is:
root@lake-cluster-manager:/# nslookup lake-service
Server: 10.3.0.10
Address: 10.3.0.10#53
Name: lake-service.default.svc.cluster.local
Address: 10.3.0.128
From the comments, it sounds like you got this to work.
Traffic to service IPs is forwarded via kube-proxy, either through a user-space proxy or through iptables rules, depending on the Kubernetes release version and configuration. You may want to look at the iptables rules for the node corresponding to that container to see if that could be the source of the problem.
since Kubernetes v1.10 kubectl port-forward
allows using resource name, such as a service name, to select a matching pod to port forward With this connection in place you can use your local workstation to debug the application that is running in the pod.
capture your pod PORT NUMBER
kubectl get pods [YOUR_PODE_NAME] --template='{{(index (index .spec.containers 0).ports 0).containerPort}}{{"\n"}}'
let's say we got PORT NUMBER 8080
kubectl port-forward [YOUR_PODE_NAME] 8080:8080
Now Navigate to http://localhost:8080/ on your local machine to see your application running