K3S Rancher - Debian based docker images not resolving dns properly

6/29/2020

I am facing strange problem.

What I've done:

I deployed Rancher K3S cluster and there is a problem in dns resolving with debian based images. Domains are not resolved properly - it adds suffix to it with one of ours domain.

What I've found:

Debian based image adds suffix with domain to the end. e.g. I ping google.com and its pinging google.com.example.com. (example.com is one of our domains - not specifing it because it is not important imo)

The same for curl google.com makes request to ip address of example.com . Even tried pure debian image and it is still doing the same issue.

Alpine based images works fine (ping to google.com pings google.com, nslookup shows right ip address).

Host server where k3s is installed also works fine (redhat os). Ping to google.com pings google.com.

Some additional data that can maybe help you:

CoreDNS configmap kubectl -n kube-system get configmap coredns -o go-template={{.data.Corefile}}

.:53 {
    errors
    health
    ready
    kubernetes cluster.local in-addr.arpa ip6.arpa {
      pods insecure
      upstream
      fallthrough in-addr.arpa ip6.arpa
    }
    hosts /etc/coredns/NodeHosts {
      reload 1s
      fallthrough
    }
    prometheus :9153
    forward . 8.8.8.8
    cache 30
    loop
    reload
    loadbalance
}

Does anyone faced the same or similar problem? Do you have some points to push me towards solving?

Thanks, David

-- Zoidik
dns
k3s
kubernetes
networking
resolve

1 Answer

11/24/2020

I faced similar issues with k3s (v.v1.19.3+k3s3) on centos 8 (not quite sure it has anything to do with the images' OS, though). k3s is a bit less plug and play that other distro like microk8s.

Use local DNS parameter

On each node, you could say that you want to use the host's resolv parameters. If k3s is managed as systemd service (which is probably the case), you could just edit /etc/systemd/system/k3s.service.env to add you system's resolv.conf

K3S_RESOLV_CONF=/etc/resolv.conf

and then restart the service

sudo systemctl status k3s
  • plus: the easiest solution, easily scriptable
  • cons: you'll need to do it on each of your nodes (from what I understand). Different resolv.conf on different systems involves that the very same deployment might not act the same way depending on the nodes used by kube

    relevant documentation

Use Global DNS

Haven't tried but here is the doc

-- zar3bski
Source: StackOverflow