Skip to content

Instantly share code, notes, and snippets.

@torsten-online
Last active November 17, 2023 21:56
Show Gist options
  • Save torsten-online/092df9369e47862f97d28e4c702f5ab4 to your computer and use it in GitHub Desktop.
Save torsten-online/092df9369e47862f97d28e4c702f5ab4 to your computer and use it in GitHub Desktop.

DNS Issue K3S + Rancher with OpenSuSE MicroOS

If you run into the issue, that DNS Resolving is not possible with K3S, Rancher, OpenSuSE MicroOS and SELinux enabled:

Please make sure, that the following Settings at K3S SystemD Unit are enabled:

  • /etc/systemd/system/k3s.service
ExecStart=/usr/local/bin/k3s \
    server \
        '--cluster-init' \
        '--selinux' \
        '--resolv-conf=/etc/resolv.conf' \

Using the /etc/resolv.conf seems not to be the "working" default setting at OpenSuSE MicroOS, but CoreDNS Config shows these setting, so I dont really understand - why these was not working:

kubectl get cm coredns -o yaml -n kube-system
apiVersion: v1
data:
  Corefile: |
    .:53 {
        errors
        health
        ready
        kubernetes cluster.local in-addr.arpa ip6.arpa {
          pods insecure
          fallthrough in-addr.arpa ip6.arpa
        }
        hosts /etc/coredns/NodeHosts {
          ttl 60
          reload 15s
          fallthrough
        }
        prometheus :9153
        forward . /etc/resolv.conf
        cache 30
        loop
        reload
        loadbalance
    }
    import /etc/coredns/custom/*.server
  NodeHosts: |
    192.168.1.100 my-k3s-master
    192.168.1.101 my-k3s-node1
kind: ConfigMap
metadata:
  annotations:
    objectset.rio.cattle.io/id: ""
    objectset.rio.cattle.io/owner-gvk: k3s.cattle.io/v1, Kind=Addon
    objectset.rio.cattle.io/owner-name: coredns
    objectset.rio.cattle.io/owner-namespace: kube-system
  labels:
    objectset.rio.cattle.io/hash:
  name: coredns
  namespace: kube-system

It is also possible with the daemon-settings, to use another dns server config, e.g. at /etc/rancher/k3s/resolv.conf

Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment