Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CoreDNS do not respect local DNS

I am running a k3s cluster on some raspberry pi 4, in my local network. I have a DNS server (dnsmasq) on the master nodes. I want that the pods of my cluster use that DNS server, via coredns. However when I ping an adress from within a pod I always pass via the google DNS servers and overpass my local DNS rules.

apiVersion: v1
kind: ConfigMap
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 . /etc/resolv.conf
        cache 30
        loop
        reload
        loadbalance
    }

this is my coredns config. As you see there is the forward . /etc/resolv.conf

my /etc/resolv.conf

domain home
nameserver 127.0.0.1

Any suggestions ?

like image 918
samsja Avatar asked Dec 30 '25 12:12

samsja


1 Answers

thanks guys I change my coredns to

kind: ConfigMap
metadata:
  annotations:
  name: coredns
  namespace: kube-system
apiVersion: v1
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 . <master node ip>
        cache 30
        loop
        reload
        loadbalance
    }
  NodeHosts: |
    <master node ip> master
    <slave node ip> slave

and it worked !

like image 167
samsja Avatar answered Jan 01 '26 08:01

samsja



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!