Multi-node CoreDNS in k3s

Created: — modified: — tags: k8s

How to make CoreDNS deployment in your multi-node k3s cluster more resilient to node failures

By default, k3s runs with only one instance (replica) of CoreDNS - essential utility which provides DNS for service discovery. It gets scheduled on one of nodes, and if that node goes down - so does CoreDNS, and cluster-wide DNS resolution for the rest of cluster. It will be rescheduled on another node, eventually, but often i'm not as patient.

A solution is to run multiple instances of CoreDNS - they will spread among multiple nodes by default, nice. You can use the official way of Customizing Packaged Components - but does this require you running the k3s-bundled Helm Controller1?

A simpler way is to just scale the deployment to three replicas:

kubectl -n kube-system scale deployment coredns --replicas=3

And voilà! You have three instances of coredns on three different nodes, and DNS requests will be spread equally among them.

  1. In my case, k3s was shipped with a simple manifests, and HelmChartConfig had no effect on it anyway. ↩