<p>I am trying to install a DNS Server inside a local Kubernetes cluster using microK8S, but I cannot reach DNS.</p>

<p>Here deployments script:</p>

<pre><code>---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: bind
  labels:
    app: bind
spec:
  replicas: 1
  selector:
    matchLabels:
      app: bind
  template:
    metadata:
      labels:
        app: bind
    spec:
      containers:
        - name: bind
          image: sameersbn/bind
          env:
            - name: ROOT_PASSWORD
              value: "toto"
          volumeMounts:
            - mountPath: /data
              name: data
          ports:
            - containerPort: 53
              protocol: UDP
            - containerPort: 53
              protocol: TCP
            - containerPort: 10000
      volumes:
        - name: data
          emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
  name: bind-dns
  labels:
    name: bind-dns
spec:
  type: ClusterIP
  ports:
    - name: dns
      port: 53
      targetPort: 53
      protocol: UDP
    - name: dns-tcp
      port: 53
      protocol: TCP
      targetPort: 53
  selector:
    name: bind
</code></pre>

<p>service is expose with ip</p>

<pre><code>bind-dns        LoadBalancer   10.152.183.144   &lt;pending&gt;     53/UDP,53/TCP     11m
</code></pre>

<p>When I ssh into bind pod it works</p>

<pre><code>host www.google.com 0.0.0.0
Using domain server:
Name: 0.0.0.0
Address: 0.0.0.0#53
Aliases: 

www.google.com has address 172.217.13.132
www.google.com has IPv6 address 2607:f8b0:4020:805::2004
</code></pre>

<p>But outside container it does not</p>

<pre><code>host www.google.com 10.152.183.144
;; connection timed out; no servers could be reached
</code></pre>

<p>What is wrong ? Why I cannot reach server ?</p>

Woody
<p>Service resource <code>spec.selector</code> need to specify pod <code>spec.metadata.labels</code>.<br>
So I think you need to change the Service resource of the yaml file.</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: bind-dns
  labels:
    name: bind-dns
spec:
  type: ClusterIP
  ports:
    - name: dns
      port: 53
      targetPort: 53
      protocol: UDP
    - name: dns-tcp
      port: 53
      protocol: TCP
      targetPort: 53
  selector:
    app: bind # changed
</code></pre>
