<p>I'm using google container engine and I can create pods and services in my cluster. But when I try to use the DNS feature (skydns) to lookup my services nothing is being found. If I log in to the non-master node, I can see the DNS container and can use 'host' command to do DNS lookup (installed with apt-get). But I can't find my service by it's name. It associates kubernetes.local with the IP of the service. Actually it associates kubernetes.local with the IP of every one of my services (I have 9). But it does not associate the service name "my-service-name".</p>

<p>Anyone know the trick to get this to work? Either creating the service isn't causing skydns to create the DNS entry (maybe there is some magic to make it work)...or I'm just completely clueless (less magical, perhaps more likely).</p>

<p>I don't know which.</p>

<p>b</p>

<p>There's a little bit of magic involved that's intended to make DNS in Kubernetes more convenient from within a pod. Let me try to explain.</p>

<p>The way that the DNS names are constructed within Kubernetes is <code>&lt;service-name&gt;.&lt;namespace&gt;.kubernetes.local</code>. This is why <code>kubernetes.local</code> is resolving from on your node, but <code>my-service-name</code> isn't. Assuming your service is defined in the default namespace (it will be unless you explicitly created it in a different namespace), you should be able to resolve it at <code>my-service-name.default.kubernetes.local</code>.</p>

<p>The docs around DNS assume that you care about how to resolve service names from within a pod rather than directly on the host. Within your pod, DNS should be set up to first search for names you specify relative to <code>default.kubernetes.local</code> and <code>kubernetes.local</code>, meaning that from within any pod in the cluster that isn't kube-dns (it's handled specially) you should be able to resolve your service using either <code>my-service-name</code> or <code>my-service-name.default.kubernetes.local</code>.</p>

<p>If you want to try it out, attach to one of your cluster's fluentd pods using docker exec and try looking up your service from within the container.</p>

<p>Note that the namespace changed from <code>kubernetes.local</code> to <code>cluster.local</code> between versions 0.17.0 and 0.18.0, so check your cluster's version (using <code>kubectl version</code>) if your first attempt doesn't work.</p>
