-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
rootless: enable resource limitation (requires cgroup v2, systemd) #3005
Conversation
c1433b8
to
bb3ece2
Compare
bb3ece2
to
2d682ae
Compare
Signed-off-by: Akihiro Suda <[email protected]>
Now rootless mode can be used with cgroup v2 resource limitations. A pod is executed in a cgroup like "/user.slice/user-1001.slice/[email protected]/k3s-rootless.service/kubepods/podd0eb6921-c81a-4214-b36c-d3b9bb212fac/63b5a253a1fd4627da16bfce9bec58d72144cf30fe833e0ca9a6d60ebf837475". This is accomplished by running `kubelet` in a cgroup namespace, and enabling `cgroupfs` driver for the cgroup hierarchy delegated by systemd. To enable cgroup v2 resource limitation, `k3s server --rootless` needs to be launched as `systemctl --user` service. Please see the comment lines in `k3s-rootless.service` for the usage. Running `k3s server --rootless` via a terminal is not supported. When it really needs to be launched via a terminal, `systemd-run --user -p Delegate --tty` needs to be prepended to create a systemd scope. Signed-off-by: Akihiro Suda <[email protected]>
2d682ae
to
2780334
Compare
@dweomer @ibuildthecloud PTAL |
Thanks for merging. I'd like to add CI for this after #2887 (or its equivalent) gets merged. |
Is there public documentation for this somewhere, that steps people through the process? |
Rootless is still kinda experimental and not very well documented. @AkihiroSuda would you mind taking a shot at the docs? I think this bit in particular could use a writeup:
|
I added some basic docs to https://rancher.com/docs/k3s/latest/en/advanced/#running-k3s-with-rootless-mode-experimental Let me know if I have to add more |
Proposed Changes
rootless: enable resource limitation (requires cgroup v2, systemd)
Types of Changes
New Feature
Verification
Install Ubuntu 20.10
Add
systemd.unified_cgroup_hierarchy=1
to kernel cmdline (/etc/default/grub
) to enable cgroup v2Enable systemd delegation (https://rootlesscontaine.rs/getting-started/common/cgroup2/)
Copy
k3s-rootless.service
to~/.config/systemd/user/k3s-rootless.service
Run
systemctl --user daemon-reload
Run
systemctl --user enable --now k3s-rootless
Run
KUBECONFIG=~/.kube/k3s.yaml kubectl get pods -A
. Make sure the pods are running.Run a test pod like this:
Linked Issues
Issue #3004
Further Comments
Now rootless mode can be used with cgroup v2 resource limitations.
A pod is executed in a cgroup like
/user.slice/user-1001.slice/[email protected]/k3s-rootless.service/kubepods/podd0eb6921-c81a-4214-b36c-d3b9bb212fac/63b5a253a1fd4627da16bfce9bec58d72144cf30fe833e0ca9a6d60ebf837475
.This is accomplished by running
kubelet
in a cgroup namespace, and enablingcgroupfs
driver for the cgroup hierarchy delegated by systemd.To enable cgroup v2 resource limitation,
k3s server --rootless
needs to be launched assystemctl --user
service.Please see the comment lines in
k3s-rootless.service
for the usage.Running
k3s server --rootless
via a terminal is not supported and results in disabling cgroup.To run
k3s server --rootless
on a terminal forcibly,systemd-run --user -p Delegate --tty
needs to be prepended to create a systemd scope.