Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use Kubernetes DNS for pods?

On GKE, kube-dns is running on my nodes, I can see the docker containers.

I do have access to Services by name, which is great for all these applications where load balancing is a perfectly suitable solution, but how would I use the DNS to access individual pods?

I know I can look up specific pods in the API, but I need to update the hosts file myself, and keep watching the pod list. DNS is supposed to do that for me so how is it meant to be used within a pod?

The Kubernetes doc says the DNS info needs to be passed to the kubelet but I have no access to that on GKE that I know of, so is it just not setup that way on GKE or is there something to do to activate it?

Some of my services (zookeeper in particular) is aware of other nodes on its own, and tries to connect to them by host name (that is pod name) and that fails unless I update the hosts file myself. I would like to use the integrated DNS service for that.

Any guidance on how to do this would be appreciated.

Thanks

like image 830
MrE Avatar asked Sep 03 '15 17:09

MrE


1 Answers

UPDATE

According to the docs, the format is now:

_my-port-name._my-port-protocol.my-svc.my-namespace.svc.cluster.local

See the related doc here: https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pods

ORIGINAL ANSWER:

as of this date, this is actually not possible... but it is being looked at by the Kubernetes team.

See this issue : https://github.com/kubernetes/kubernetes/issues/13552

UPDATE:

DNS is available for Pods since 09/2015 See PR:https://github.com/kubernetes/kubernetes/pull/13759

in short:

This will give pods dns in the form of <podIP>.<namespace>.pod.<clusterSuffix> Currently can be disabled, but is either on for all pods or off.

like image 175
MrE Avatar answered Oct 13 '22 01:10

MrE