k3s custom dns - elraro/home-ops GitHub Wiki

Create a file /etc/rancher/k3s/resolv.conf with the following data.

vi /etc/rancher/k3s/resolv.conf

nameserver <DNS_IP_1>
nameserver <DNS_IP_2>
search <DOMAIN_1> <DOMAIN_2>

Edit /etc/rancher/k3s/config.yaml with the following data.

kubelet-arg:
  - "resolv-conf=/etc/rancher/k3s/resolv.conf"

Now restart the k3s service using following command.

service k3s restart

Delete coredns pod using the following command.

kubectl delete pod $(kubectl get pod -n kube-system | grep coredns | awk '{print }') -n kube-system

Run the following command to verify whether the DNS has been updated.

kubectl debug -it $(kubectl get pod -n kube-system | grep coredns | awk '{print }') -n kube-system --image=busybox:1.28 --target=coredns -- cat /etc/resolv.conf

Source: https://docs.opsramp.com/platform-features/nextgen-gateways/how-to-guide/manually-add-dns-name/

⚠️ **GitHub.com Fallback** ⚠️