<p>I was following <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">this kubernetes tutorial</a> in order to set up a <code>DNS service</code> and connect together two separate <code>kubernetes pods</code>. The one, which should serve as a gateway, is listening on port 80, the other one on port 90.</p>

<p>When I use their Node IP, <code>curl 10.32.0.24</code> and <code>curl 10.32.0.25:90</code>  I can reach them. Nevertheless I can't figure out, how to access them via my DNS service. What the <code>URL</code> will be?</p>

<p>The <code>Namespace</code> is <code>default</code> and this is the result of <code>kubectl cluster-info:</code>
<code>
Kubernetes master is running at IP_OF_MY_SERVER:6443
KubeDNS is running at IP_OF_MY_SERVER:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
</code>
My <code>deployment.yaml</code> is almost the same as in the tutorial:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: default-subdomain
spec:
  selector:
    name: busybox
  clusterIP: None
  ports:
  - name: foo # Actually, no port is needed.
    port: 80
    targetPort: 80
---
apiVersion: v1
kind: Pod
metadata:
  name: busybox1
  labels:
    name: busybox
spec:
  hostname: busybox-1
  subdomain: default-subdomain
  containers:
  - image: time-provider
    name: busybox
---
apiVersion: v1
kind: Pod
metadata:
  name: busybox2
  labels:
    name: busybox
spec:
  hostname: busybox-2
  subdomain: default-subdomain
  containers:
  - image:  gateway
    name: busybox
</code></pre>

<p>The Kubernetes DNS service works inside a cluster and provide DNS names for pods, not for external services.</p>
<p>Here is an extract from the <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">instruction</a> you used:</p>
<blockquote>
<p>Every Service defined in the cluster (including the DNS server itself) is assigned a DNS name. By default, a client Pod’s DNS search list will include the Pod’s own namespace and the cluster’s default domain. This is best illustrated by example:</p>
<p>Assume a Service named <code>foo</code> in the Kubernetes namespace <code>bar</code>. A Pod running in namespace <code>bar</code> can look up this service by simply doing a DNS query for <code>foo</code>. A Pod running in namespace <code>quux</code> can look up this service by doing a DNS query for <code>foo.bar</code>.</p>
</blockquote>
<p>So, the DNS names of your resources inside a cluster exist only in it.</p>
<p>You call to the service from the external network by NodeIPs : <code>curl 10.32.0.24</code> and <code>curl 10.32.0.25:90</code>. And that is a correct way. If you want to use a DNS names to connect to the cluster from outside, you should use any other DNS service to point names to your cluster nodes or LoadBalancer.</p>
<p>I recommend you to use <code>Service</code> object to expose your application. Here is a some articles about it: <a href="https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/#ways-to-connect" rel="nofollow noreferrer">ways to connect</a>, <a href="https://kubernetes.io/docs/tasks/access-application-cluster/service-access-application-cluster/" rel="nofollow noreferrer">use a Service to access applications.</a></p>
