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

Configuration directory different than /etc/rancher/ #11473

Closed
rorosen opened this issue Dec 17, 2024 · 4 comments
Closed

Configuration directory different than /etc/rancher/ #11473

rorosen opened this issue Dec 17, 2024 · 4 comments

Comments

@rorosen
Copy link
Contributor

rorosen commented Dec 17, 2024

Is your feature request related to a problem? Please describe.

I run k3s server on a system with volatile root where only specific paths are persisted across reboots. The inability of changing the configuration directory to something other than /etc/rancher and k3s not following directory symlinks at /etc/rancher make it very hard for me to persist the content of /etc/rancher. Unfortunately, mounts also don't work for me in combination with systemd-confext.

Describe the solution you'd like

My problem would be solved if I could point k3s to another configuration directory. Is this already possible and I'm missing something here? I didn't find a way to set it to another path, please let me know if this is already possible.

Describe alternatives you've considered

It would be also ok if k3s would follow symlinks, currently it errors with file exists when a symlink exists at /etc/rancher.

Additional context

Is there anything speaking against making this configurable? If not, I could try to contribute a PR for it.

@brandond
Copy link
Member

brandond commented Dec 18, 2024

The /etc/rancher file locations are not currently configurable. The error when it's a symlink is unexpected, we can look at that.

Have you tried symlinking /etc/rancher/node and /etc/rancher/k3s individually? Do you get the same behavior?

@rorosen
Copy link
Contributor Author

rorosen commented Dec 18, 2024

Have you tried symlinking /etc/rancher/node and /etc/rancher/k3s individually?

I just tried this but it results in the same error

level=error msg="Failed to generate kubeconfig: mkdir /etc/rancher/k3s: file exists"

For reference, this is the error I get when only symlinking /etc/rancher/

level=error msg="Failed to generate kubeconfig: mkdir /etc/rancher: file exists"

I tried with v1.30.6+k3s1 and v1.31.2+k3s1 but the error is the same. It seems to fail when calling WriteToFile() in WriteClientKubeConfig().

@rorosen
Copy link
Contributor Author

rorosen commented Dec 18, 2024

The problem was the target of the symlink at /etc/rancher didn't exist. os.MkDirAll() doesn't create a directory at the target location if it doesn't exist and I guess that is expected. It works if I create the directory to which /etc/rancher points.

Sorry for the noise, I had the wrong idea of how a symlink is treated in this case.

@brandond
Copy link
Member

brandond commented Dec 19, 2024

It works if I create the directory to which /etc/rancher points.

Well yeah, that seems important. I wouldn't expect it to work with a broken symlink.

@github-project-automation github-project-automation bot moved this from New to Done Issue in K3s Development Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done Issue
Development

No branches or pull requests

2 participants