Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service resolution doesn't work in minikube #314

Closed
vskr opened this issue Jul 12, 2016 · 8 comments
Closed

Service resolution doesn't work in minikube #314

vskr opened this issue Jul 12, 2016 · 8 comments

Comments

@vskr
Copy link

vskr commented Jul 12, 2016

Hello

Copying a question I have asked on stackoverflow couple of days back

I installed minikube to use kubernetes locally. I was able to create pods and services locally.

However, pods (and containers) running on them, cannot resolve services using service names.

Example: I have redis service running that acts a proxy for redis pods.

kubectl get services shows taht redis service has been created.

However, when my web application tries to connect to redis-service, I get connection timeout, because web application (pod) cannot resolve redis-service.

Is there anything special taht needs to be installed to get service resolution working locally.

this is the output of running kubectl get services

 frontend            10.0.0.250                 80/TCP      3h
 kubernetes          10.0.0.1     <none>        443/TCP     3h
 redis-service       10.0.0.156   <none>        6379/TCP    3h
 rethinkdb-service   10.0.0.89    <none>        28015/TCP   3h






kubectl describe services --namespace=kube-system

Name:                   kube-dns
Namespace:              kube-system
Labels:                 k8s-app=kube-dns,kubernetes.io/name=KubeDNS
Selector:               <none>
Type:                   ClusterIP
IP:                     10.0.0.10
Port:                   dns     53/UDP
Endpoints:              10.0.2.15:53
Port:                   dns-tcp 53/TCP
Endpoints:              10.0.2.15:53
Session Affinity:       None
No events.

Name:                   kubernetes-dashboard
Namespace:              kube-system
Labels:                 app=kubernetes-dashboard,kubernetes.io/cluster-service=true
Selector:               app=kubernetes-dashboard
Type:                   NodePort
IP:                     10.0.0.156
Port:                   <unset> 80/TCP
NodePort:               <unset> 30000/TCP
Endpoints:              172.17.0.2:9090
Session Affinity:       None
No events.

However, same yaml files when executd in Google Container Engine work fine. They are able to find services

@jimmidyson
Copy link
Member

Can you share the logs from your application just to confirm it is DNS resolution & not service timing out or something like that? Can you also confirm that the redis pods are up & that the redis-service has valid endpoints as expected?

@dlorenc
Copy link
Contributor

dlorenc commented Jul 12, 2016

To check DNS, could you try something like this:

$ kubectl exec -it <pod> bash

Then run:
nslookup kubernetes.default

That should return something like 10.0.0.1 if DNS is working.

@dlorenc
Copy link
Contributor

dlorenc commented Jul 14, 2016

Any luck here?

@vskr
Copy link
Author

vskr commented Jul 14, 2016

I switched from 'dns' to 'env'. It worked then.

When I switched back from 'env' to 'dns', it continued working. Not sure what changed (other than discovery type), but it continued working with 'dns'.

Fyi (not sure if it matters), I am running all of this locally on a mac.

Thanks !!

@vskr
Copy link
Author

vskr commented Jul 14, 2016

More info:

My docker image is a pretty minimal ubuntu image . It doesn't have nslookup installed on it, but when I installed and ran nslookup kubernetes.default, it did show 10.0.**, which means DNS is working?

Should be a separate thread, I guess, but what are some of the best practices in debugging services. Sometimes, my services says it is in pending state on the dashboard (minikube dashboard).

And sometimes, service doesn't respond at all and times out, and I don't see any logs on my application pods (pods which are being proxied by the service). So quite sure, requests haven't reached the application pod, but are being interrupted before..

@vskr
Copy link
Author

vskr commented Jul 14, 2016

Closing this issue, since this particular issue is not a issue anymore.

@erulabs
Copy link

erulabs commented Feb 22, 2018

This is closed, but its the first thing that comes up when a newbie searches "kubernetes services dont work in minikube". Turns out, in minikube, you have to provide a GET_HOSTS_FROM environment variable.

In Kube on AWS, kube-on-mac, and every other kube environment I've used, setting no GET_HOSTS_FROM would ideally mean that GET_HOSTS_FROM defaults to dns. However, in minikube, setting:

      containers:
      - name: app
        image: myimage
        env:
          - name: GET_HOSTS_FROM
            value: dns

Seems to make services work! I believe this is still an open bug (because IMO you shouldnt have to provide that env line)

Hope this helps someone else banging their head against minikube like I was :)

@denisw
Copy link

denisw commented Mar 29, 2018

Thank you so much @erulabs! That caused a lot of confusion for me.

How come GET_HOSTS_FROM is required, but not documented in the Kubernetes tutorials I looked at (the ones linked from the tour)? Is there an GitHub issue that tracks this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants