-
Notifications
You must be signed in to change notification settings - Fork 2.3k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Disable CoreDNS host forwarding when DNS is not configured #6787
Comments
Most airgap environments I've worked with have some sort of stub resolver available. I'm not sure that adding code to actively rewrite the CoreDNS manifest to handle this corner case is worth it? Kubernetes also requires a default route (even if it just just a black-hole default route) to function properly, so I would probably lean towards leaving this as something that needs to be set up properly for airgap scenarios. |
@brandond Very good points. I did in fact run into the default route issue and solved that as you described with a blackhole default route. The DNS configuration proved to be trickier. I had initially configured a
These timeouts caused poor performance and ultimately prevented readiness probes from executing successfully. Unfortunately, the issue was intermittent, and I never was able to determine root cause. In an effort to bring the system back to a working state, I ended up removing (IIRC, I ran into different issues with At the end of the day, the experience did not give me much confidence. I felt that I was hacking around things that I expected to work out-of-the-box. I never really wanted a stub resolver, I just wanted to make K3s (CoreDNS) happy 😂. I'd like to leave this open to discussion and am happy to provide more information if needed. Hopefully others can chime in with their DNS resolver workarounds. If we feel that rewriting the CoreDNS manifest isn't worth it, maybe we can at least update the K3s Airgap documentation to address some of these requirements? Maybe with examples of supported resolver configurations? |
Yeah, I'm happy to leave it open. I will also add that most of the air-gap environments we target are air-gapped in the traditional sense that they do not have a connection to the internet. They usually do have a local network environment with functioning routing/dns/dhcp. Think secure office, remote lab, airplane, or ship. If your air-gap environment is more of a "this box isn't plugged in to anything at all" type setup, then then our docs probably don't cover your use case. |
I have added a section to the docs about needing a default route https://docs.k3s.io/installation/airgap#prerequisites |
Could you explain what you did in "configuring CoreDNS as described above." |
@thooooooomas Here's the hack I threw together to comment out the "forward" line in the Corefile after the CoreDNS manifest has been generated. This change is only made when there are no nameservers defined in /etc/resolv.conf. I'm executing it an ExecStartPost for the "k3s" systemd service:
Not very elegant, but it works 🤷♂️ |
Just going to convert this to a discussion for now |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Is your feature request related to a problem? Please describe.
When there are no DNS servers defined in
/etc/resolv.conf
, CoreDNS will not properly start -- it will remain in CrashLoopBackoff with the following error:The error from
plugin/forward
is encountered because CoreDNS is configured to forward DNS requests to the host's resolv.conf nameservers:Describe the solution you'd like
I don't expect this to be a common scenario for most, but the default Corefile prevents K3s from starting properly in an air-gapped environment where DNS is not available (and nameservers are intentionally omitted from
/etc/resolv.conf
).I think it would be reasonable for CoreDNS forwarding to be dynamically configured based on whether or not nameservers have been defined on the host -- i.e., if nameservers are present in
resolv.conf
, add theforward . /etc/resolv.conf
line; otherwise, do not. Then, if the configMap changes, trigger a rollout restart of thecoredns
deployment.Describe alternatives you've considered
As a very (VERY) crude workaround, I was able to implement the desired behavior in an
ExecStartPost
scriptlet ink3s.service
. The logic is as follows:/run/k3s/containerd/containerd.sock
to be created – this tells me that K3s has started./var/lib/rancher/k3s/server/manifests/coredns.yaml
to be created – this file has to exist before we can change it.coredns.yaml
to be newer thancontainerd.sock
(as determined by mtime) – when the manifest is newer than the containerd socket, assume K3s has touched it on startup and will not be touched again. (Probably a bad assumption?)/etc/resolv.conf
, comment out the “forward” line in the Corefile to prevent DNS requests from being forwarded to the host’s nameservers.kubectl -n kube-system rollout restart deployment coredns
.Unfortunately, I do not know Go well enough to implement this change properly 😝
Additional context
I am running K3s v1.24 in an "air-gapped" environment with an empty
/etc/resolv.conf
.Airgap images have been dropped onto the filesystem:
The text was updated successfully, but these errors were encountered: