-
-
Notifications
You must be signed in to change notification settings - Fork 466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] DNS not resolving #209
Comments
Hi there, thanks for opening this issue. |
To workaround this issue I'm patching the coredns configmap. |
@luisdavim what's the patch that you apply? |
@luisdavim I'm also interested in what patch you applied |
I'm pretty sure that adapting the This let k8s use the machine DNS when the name cannot be resolved internally. I think this should be the default behaviour. |
After more investigation I found that this could be related to the way k3d creates the docker network. Indeed, k3d creates a custom docker network for each cluster and when this happens resolving is done through the docker daemon. The requests are actually forwarded to the DNS servers configured in your host's resolv.conf. But through a single DNS server (the embedded one of docker). This means that if your It would be useful to have a custom options to provide to k3d when it starts the cluster and specify the DNS servers there, as proposed here #165 |
Thanks for your additional input @irizzant , how would you add additional DNS servers here on k3d's side? |
Personally I fixed this by injecting a custom ConfigMap for CoreDns, by changing
to:
replacing the x with the IP of your DNS servers. I had a quick look to the docker options and I confirm that I don't see an option to configure the custom DNS servers on the docker network. Maybe a feasible option would be to add a custom flag to |
Currently, k3d doesn't interact with any Kubernetes resources inside the cluster (i.e. in k3s) and I tend to avoid this because of the huge dependencies on Kubernetes libraries it could draw in. Upon cluster creation this could work however by modifying the Chart that's being auto-deployed by k3s. Not sure if this could go into k3s itself instead 🤔 |
Maybe interacting with k8s itself it's not needed. |
This only happens to me if I deploy something in the LE: just noticed it doesn't matter which namespace you deploy stuff to, it's about the network you're in. So if I'm in the office (company LAN) I get this issue, but when I'm trying it from home, it just simply works. And I cannot say what network restrictions they applied in the company 😄 Also, @Athosone 's solution works for me now |
I seem to be running into this issues about every couple of weeks. This is the only workaround that seems to "just work" so I can get back to the job I'm paid to do:
|
This seems to be broken, because the coredns pod does not have an /etc/resolv.conf in it, while the ConfigMap is configured to forward to that. All the docs have pointed told me that coredns will use the $HOST resolv.conf, but when I used k3d, which uses k3s, the coredns "pod" doesn't run as a container, or as a process on the $HOST. It runs as a process of containerd, and therefore it doesn't get any of the correct settings. |
For those who have the problem a simple fix is to mount your /etc/resolve.conf onto the cluster:
|
What does that |
From what I understand there is nothing special. It just mounts the volume to the container running the k3s server. |
Hey folks, sorry for the radio silence, just getting back to k3d now...
That's a good starting point. Unfortunately, this would require us to write the file to disk and bind mount it into the container, as exec'ing into it afterwards to update the ConfigMap manifest, wouldn't update the actual thing inside the cluster (IIRC, there is no loop to do so). It's definitely doable, but we'd need to keep state somewhere and react to changes k3s does in the auto-deploy manifests.
This is for real the weirdest thing on this thread that you're experiencing 🤔 No clue, what's going on there..
Are you executing this on your local host (I assume so because of the sudo) to just route all the Google-DNS traffic (default Docker DNS) to your own DNS server?
What do you mean by "it doesn't run as a container"? It surely is running in a container 🤔
Also, those two statements seem to conflict, right?
It's doing basically the same as docker's Is anyone experiencing this on a Linux machine or in WSL2, i.e. in Docker versions which do not run inside a VM? |
Well maybe it conflicts but for me it solves the problem. |
@Athosone , I meant, that CoreDNS does indeed pick up the |
Just as a clarification, if you modify the docker daemon configuration (daemon.json) to add the company DNS and then you launch the k3d cluster you can "docker exec" into the containers where k8s running and you'll see that nslookup finds DNS entries served by company DNS. The problem is that the default forward . /etc/resolv.conf which forces CoreDNS to use its own |
When I run k3d cluster create, I can certainly volume mount $HOST files into the docker containers(agent+server). However, containerd is then used to start the CoreDNS pod, running inside k8s. It is this internal container that needs to have an /etc/resolv.conf. Nothing I do to the k3d command will allow me to adjust the internal containerd/pod that is created. I did a bit of research, trying to figure out that this was the case, by figuring out where containerd stores it's filesystems. |
I am running k3d in a Docker that runs in VM in Virtual Box (actually I'm using And I'm experiencing the same problem
I can see that my VM in Virtual Box and all containers running inside it are using proper DNS configurations, but pods - not. |
Mounting the resolv.conf works but this can't be the best solution. If you missed that oppertunity at the beginning you need to re-create a k3d cluster just to mount that volume.
This one did not work for me. Edit: Forward is working but I need to place my DNS server in front.
|
VERY HELPFULL HINT |
@iwilltry42, awesome, running the above has both external DNS and k3d: v5.0.0-rc.5 On a side note, I'm happy to help out in general so feel free to tag me. |
Fix working and tested on
The |
Executed on ubuntu 21.04 with VPN using openconnect: |
@iwilltry42 seems that the fix is not working. I'm on 5.0.0-rc5 |
@gioppoluca , can you please provide some more information? |
The fix with the environment variable doesn't seem to be working for me as well. ❯ system_profiler SPSoftwareDataType
Software:
System Software Overview:
System Version: macOS 11.6 (20G165)
Kernel Version: Darwin 20.6.0
❯ k3d --version
k3d version v5.0.3
k3s version latest (default) ❯ k3d cluster create test
INFO[0000] Prep: Network
INFO[0000] Created network 'k3d-test'
INFO[0000] Created volume 'k3d-test-images'
INFO[0000] Starting new tools node...
INFO[0000] Starting Node 'k3d-test-tools'
INFO[0001] Creating node 'k3d-test-server-0'
INFO[0001] Creating LoadBalancer 'k3d-test-serverlb'
INFO[0001] Using the k3d-tools node to gather environment information
WARN[0001] failed to resolve 'host.docker.internal' from inside the k3d-tools node: Failed to read address for 'host.docker.internal' from command output
INFO[0001] HostIP: using network gateway...
INFO[0001] Starting cluster 'test'
INFO[0001] Starting servers...
INFO[0001] Deleted k3d-test-tools
INFO[0001] Starting Node 'k3d-test-server-0'
INFO[0005] Starting agents...
INFO[0005] Starting helpers...
INFO[0005] Starting Node 'k3d-test-serverlb'
INFO[0012] Injecting '172.27.0.1 host.k3d.internal' into /etc/hosts of all nodes...
INFO[0012] Injecting records for host.k3d.internal and for 2 network members into CoreDNS configmap...
INFO[0012] Cluster 'test' created successfully! Also, the fix with volume creation also doesn't seem to be working: ❯ k3d cluster create --volume /etc/resolv.conf:/etc/resolv.conf
WARN[0000] No node filter specified
INFO[0000] Prep: Network
INFO[0000] Created network 'k3d-k3s-default'
INFO[0000] Created volume 'k3d-k3s-default-images'
INFO[0000] Starting new tools node...
INFO[0000] Starting Node 'k3d-k3s-default-tools'
INFO[0001] Creating node 'k3d-k3s-default-server-0'
INFO[0001] Creating LoadBalancer 'k3d-k3s-default-serverlb'
INFO[0001] Using the k3d-tools node to gather environment information
WARN[0001] failed to resolve 'host.docker.internal' from inside the k3d-tools node: Failed to read address for 'host.docker.internal' from command output
INFO[0001] HostIP: using network gateway...
INFO[0001] Starting cluster 'k3s-default'
INFO[0001] Starting servers...
INFO[0001] Deleted k3d-k3s-default-tools
INFO[0001] Starting Node 'k3d-k3s-default-server-0'
ERRO[0001] Failed Cluster Start: Failed to start server k3d-k3s-default-server-0: Node k3d-k3s-default-server-0 failed to get ready: error waiting for log line `k3s is up and running` from node 'k3d-k3s-default-server-0': stopped returning log lines
ERRO[0001] Failed to create cluster >>> Rolling Back
INFO[0001] Deleting cluster 'k3s-default'
INFO[0001] Deleted k3d-k3s-default-serverlb
INFO[0001] Deleted k3d-k3s-default-server-0
INFO[0001] Deleting cluster network 'k3d-k3s-default'
INFO[0001] Deleting image volume 'k3d-k3s-default-images'
FATA[0001] Cluster creation FAILED, all changes have been rolled back! |
Hi @parg0MakSystem, can you provide some more information as per #209 (comment), please? Additionally, you're hitting another issue here:
This is because with |
Sorry for reopening this issue, but I'm really disappointed. I'm running K3D behind a corporate DNS+HTTP Proxy. I suspect that CoreDNS is still unable to use my local-host DNS resolution (Ubuntu 20.04). Any help appreciated. PS: I restarted the cluster between its creation and the add of workload: is there any impact related to K3D_FIX_DNS feature? |
Sorry (again): it seems my previous issue was due to Docker daemon. I'm using a VPN. It seems that Docker daemon pick the DNS resolution config at start (outside VPN) and does not update when VPN was activated. It still continue to use the DNS of my local network, not the corporate one. |
I shouldn't start a separate thread, so I'm adding my comment here. New feature works for me. My set-up is described in #1042. After setting environment and create a test cluster, I saw this:
It did resolve 172.20.30.106 but I can't reach it. Though I suspect there is an address conflict with docker network 172.20.XXX.XXX? So I tried again with k3d cluster create test --subnet 172.28.0.0/16 and it worked this time. |
If so, why not configuring your docker (cf. parameter bip in daemon.json) in order to avoid conflict between docker and corporate address plan? |
FYI experiencing a similar issue on an M1 Macbook as @parg0MakSystem reported, although I'm using colima (which could be related ie. abiosoft/colima#341) Tried to use Used |
Today I migrated one of my projects from KinD to K3D, and I immediately found this issue. Using In my case, I'm not running behind Docker Desktop, or even a corporate VPN. It failed to resolve I just wonder if |
|
It will definitely move to default 👍 |
Got it. Thank you! |
We've run into an issue with This is because of 2 extra lines added to iptables for DNS NAT for host 127.0.0.11, which caused DNS resolution to fail. |
@irizzant , got a heads-up on this issue, so I'm just reading your reply now. |
Thanks a lot for the great work while searching a solution for the issue! Using However, it seems that it's not yet the default behavior with k3d v5.6.0. Any plan on this front @iwilltry42? |
I am facing the issue that DNS does not work on mobile network (mobile hotspot)... the browser works seamlessly Unfortunatly neither any hints/help are highly appreciated. |
Hey sorry to reopen this. At my company some scripts use |
Both |
What did you do?
Start a pod and try a DNS query:
Exec into the
k3d
container and do the same DNS query:What did you expect to happen?
I would expect the pods in the k3d cluster to be able to resolve DNS names
Which OS & Architecture?
MacOS 10.15.3
Which version of
k3d
?k3d --version
Which version of docker?
docker version
The text was updated successfully, but these errors were encountered: