Add-on dns

1.12
Compatibility: amd64 arm64 power s390 strict classic
Source: CoreDNS

This deploys CoreDNS to supply address resolution services to
Kubernetes.

This service is commonly required by other addons, so it is
recommended that you enable it.

microk8s enable dns

By default it forwards requests to the system-defined servers in /etc/resolv.conf for resolving
addresses. This can be changed when you enable the addon, for example:

microk8s enable dns:1.1.1.1

(for multiple DNS addresses, a comma-separated list should be used)

The forward dns servers can also be altered after enabling the addon
by running the command:

microk8s kubectl -n kube-system edit configmap/coredns

This will invoke the vim editor so that you can alter the configuration.

Note: You can set a different default editor by setting the KUBE_EDITOR environment variable. E.g. export KUBE_EDITOR="/usr/bin/nano"

The addon can be disabled at any time:

microk8s disable dns

…but bear in mind this could have implications for services and pods which
may be relying on it.

2 Likes

Good afternoon

When I execute:

microk8s enable dns:MY-INTERNAL-DNS

if I use one server is ok, but two ou more the resolution is broken.

are you using the right syntax? The scripts which enable it support a comma separated list, e.g:

microk8s enable dns:8.8.8.8,8.8.4.4

Good Morning.

Alright?

In this case, I can successfully configure the internal DNS, as long as I use only one server. When I add two or more the resolution stops working.

I believe this problem is specific, but I would like continue using the mk8s, but in this moment is impossible.

The issue is resolving hosts that is not within the cluster? From pod to pod does it work?
Thanks

When I change the DNS configuration to my internal DNS, example 192.168.10.10 (DNS server), it works for both the internal addresses on my network and the public ones. Also the svc cluster address.

The problem occurs when I increase the number of cluster nodes. Resolution no longer works.

I would add to the docs something along the lines of:

You can verify the addon is ready using:
sh -c "until microk8s.kubectl rollout status deployments/coredns -n kube-system -w; do sleep 5; done"

I’m having the same issue with microk8s. Everything was working perfect with a single node. After adding another node, pods that are deployed there can’t be accesible.

If i try “microk8s kubectl get pods --all-namespaces” I can see that the pods are there. But if i try “microk8s kubectl exec -it name-of-pod bash” it doesn’t work. It seems a DNS issue as I also tried 'ping name-of-pod" and it can’t resolve.

In the dashboard I can see everything up and running, but the apps are broken.

Kind of sad that multinode are not fully working (or maybe i’m making a mistake…)

Any suggestion?

Try adding your node’s hostname and IP to each of the cluster node’s /etc/hosts

Hi,

May I know any instructions for the end-user to change the daemonset to put the selector like kubernetes.io/os=linux. e.g. Coredns? Thanks!

hello, i have tried editing the core dns with

microk8s kubectl -n kube-system edit configmap/coredns

After editing it gives output:

configmap/coredns edited

But after looking at the configmap again in the last applied configuration section, it is still the old one applied. I have tried rollout restart, deleting pods, rescaling deployments, but none change the last applied configuration. The only way that i found that is able to change the configmap is by disabling dns and enabling it again. Please help.

Edit: Solved by re-applying the coredns configmap yaml
kubectl apply -f {coredns.yaml}

I would have thought restart would have been sufficient. @kjackal?

Solved my problem, by re applying the coredns configmap using commands in my edit.

1 Like

We are also facing same issue when enabled dns in multi node environment.
Any idea on how to resolve this issue @rzlrogerio @mikhatanu

try increasing the pod number of coredns so it matched the node number (e.g. if you have 3 nodes, set pod number to 3)

@mikhatanu i did increase the replicas. still same issue infrequent timeout issue occurs while connecting to internet.

@mikhatanu can you let us know how did you resolve coredns issue in multi-node environment?

Hi,
It says it points to Google’s 8.8.8.8 and 8.8.4.4 servers but by default coredns ConfigMap has forward . /etc/resolv.conf

Can you confirm please?

1 Like

Hi, I can confirm this behavior. Default is: forward . /etc/resolv.conf

microk8s version
MicroK8s v1.27.5 revision 5891
1 Like