Skip to content
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

Validate resolv.conf for presence of nameserver entries #9874

Closed
x-coder-L opened this issue Apr 7, 2024 · 6 comments
Closed

Validate resolv.conf for presence of nameserver entries #9874

x-coder-L opened this issue Apr 7, 2024 · 6 comments
Assignees
Milestone

Comments

@x-coder-L
Copy link

Is your feature request related to a problem? Please describe.
We are currently using k3s version 1.28.4 and have encountered an issue. If the /etc/resolv.conf file lacks any nameserver entries, the coredns pod fails to run. However, if the /etc/resolv.conf file is absent, coredns operates correctly.
Describe the solution you'd like

We suggest that if the /etc/resolv.conf file lacks any nameserver entries, the k3s agent should generate a resolv.conf file. This would allow coredns to run properly.
Describe alternatives you've considered

Upon examining the k3s code, we found a section in k3s/pkg/agent/config/config.go that validates the resolv.conf file. We propose adding a check here to validate the presence of nameserver entries in resolv.conf.

func isValidResolvConf(resolvConfFile string) bool {

Additional context

@yashvardhan-kukreja
Copy link

Hi, I would love to contribute to this one if this gets accepted.
Looks like an interesting issue to work on as my first contribution to k3s :)

@x-coder-L
Copy link
Author

x-coder-L commented Apr 9, 2024

I’m glad you’ve taken notice of this issue. I believe we can enhance it together through discussion.
I think this is a small and easy change for this feature.However, I’m uncertain if resolving my problem in the isValidResolvConf function is appropriate.
Additionally, I’m curious as to why k3s generates an agent-resolv.conf under such circumstances. I haven’t found any documentation indicating that k3s will generate a resolv.conf file.

Hi, I would love to contribute to this one if this gets accepted. Looks like an interesting issue to work on as my first contribution to k3s :)

@brandond
Copy link
Member

brandond commented Apr 9, 2024

I’m uncertain if resolving my problem in the isValidResolvConf function is appropriate.

I think that's a fine place to do it. As far as k3s is concerned, not having any upstream is just as invalid as having multicast/loopback upstreams.

I’m curious as to why k3s generates an agent-resolv.conf under such circumstances. I haven’t found any documentation indicating that k3s will generate a resolv.conf file.

K3s has always done this, but you're correct that we could probably enhance the documentation to cover the behavior.

As far as why it does it - many hosts use systemd-resolved or another local stub resolver. This does not work within pods, as the loopback address used for the stub is not reachable outside the host network namespace. Using a default upstream (8.8.8.8) in this case provides default behavior that works for most users.

@x-coder-L
Copy link
Author

Kindly to ask if there is somebody working for this issue?If not I'm gald to undertake it.

@yashvardhan-kukreja
Copy link

I see that you have already raised the PR, so yeah I think you can take it over.
Thanks!

@fmoral2
Copy link
Contributor

fmoral2 commented Jun 6, 2024

fixed here

#10302

@fmoral2 fmoral2 closed this as completed Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

6 participants