Skip to content

Commit 59ad3d6

Browse files
committed
Tweak the kubelet in user namespace page
This PR fixes some nits in the page and adds some links for the convenience of users.
1 parent 9dce5a7 commit 59ad3d6

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

content/en/docs/tasks/administer-cluster/kubelet-in-userns.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ If you are just looking for how to run a pod as a non-root user, see [SecurityCo
2727
* [Enable systemd with user session](https://rootlesscontaine.rs/getting-started/common/login/)
2828
* [Configure several sysctl values, depending on host Linux distribution](https://rootlesscontaine.rs/getting-started/common/sysctl/)
2929
* [Ensure that your unprivileged user is listed in `/etc/subuid` and `/etc/subgid`](https://rootlesscontaine.rs/getting-started/common/subuid/)
30-
31-
* `KubeletInUserNamespace` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
30+
* Enable the `KubeletInUserNamespace` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
3231

3332
<!-- steps -->
3433

@@ -86,9 +85,10 @@ Rootless Docker/Podman or LXC/LXD, you are all set, and you can go to the next s
8685
Otherwise you have to create a user namespace by yourself, by calling `unshare(2)` with `CLONE_NEWUSER`.
8786

8887
A user namespace can be also unshared by using command line tools such as:
88+
89+
- [`unshare(1)`](https://man7.org/linux/man-pages/man1/unshare.1.html)
8990
- [RootlessKit](https://github.com/rootless-containers/rootlesskit)
9091
- [become-root](https://github.com/giuseppe/become-root)
91-
- [`unshare(1)`](https://man7.org/linux/man-pages/man1/unshare.1.html)
9292

9393
After unsharing the user namespace, you will also have to unshare other namespaces such as mount namespace.
9494

@@ -123,29 +123,37 @@ On your node, systemd must already be configured to allow delegation; for more d
123123
Containers documentation.
124124

125125
### Configuring network
126+
126127
{{% thirdparty-content %}}
127128

128129
The network namespace of the Node components has to have a non-loopback interface, which can be for example configured with
129-
slirp4netns, VPNKit, or lxc-user-nic.
130+
[slirp4netns](https://github.com/rootless-containers/slirp4netns),
131+
[VPNKit](https://github.com/moby/vpnkit), or
132+
[lxc-user-nic(1)](https://www.man7.org/linux/man-pages/man1/lxc-user-nic.1.html).
130133

131134
The network namespaces of the Pods can be configured with regular CNI plugins.
132135
For multi-node networking, Flannel (VXLAN, 8472/UDP) is known to work.
133136

134137
Ports such as the kubelet port (10250/TCP) and `NodePort` service ports have to be exposed from the Node network namespace to
135-
the host with an external port forwarder, such as RootlessKit, slirp4netns, or socat.
138+
the host with an external port forwarder, such as RootlessKit, slirp4netns, or
139+
[socat(1)](https://linux.die.net/man/1/socat).
136140

137-
You can use the port forwarder from K3s; see https://github.com/k3s-io/k3s/blob/v1.21.2+k3s1/pkg/rootlessports/controller.go
141+
You can use the port forwarder from K3s.
142+
See [Running K3s in Rootless Mode](https://rancher.com/docs/k3s/latest/en/advanced/#known-issues-with-rootless-mode)
143+
for more details.
138144

139145
### Configuring CRI
140146

141-
The kubelet relies on a container runtime. You should deploy a container runtime such as containerd or CRI-O and ensure that it is running within the user namespace before the kubelet starts.
147+
The kubelet relies on a container runtime. You should deploy a container runtime such as
148+
containerd or CRI-O and ensure that it is running within the user namespace before the kubelet starts.
142149

143150
{{< tabs name="cri" >}}
144151
{{% tab name="containerd" %}}
145152

146153
Running CRI plugin of containerd in a user namespace is supported since containerd 1.4.
147154

148-
Running containerd within a user namespace requires the following configuration:
155+
Running containerd within a user namespace requires the following configurations
156+
in `/etc/containerd/containerd-config.toml`.
149157

150158
```toml
151159
version = 2
@@ -175,7 +183,7 @@ Running CRI-O in a user namespace is supported since CRI-O 1.22.
175183

176184
CRI-O requires an environment variable `_CRIO_ROOTLESS=1` to be set.
177185

178-
The following configuration is also recommended:
186+
The following configurations (in `/etc/crio/crio.conf`) are also recommended:
179187

180188
```toml
181189
[crio]
@@ -197,31 +205,32 @@ The following configuration is also recommended:
197205
Running kubelet in a user namespace requires the following configuration:
198206

199207
```yaml
200-
kind: KubeletConfiguration
201208
apiVersion: kubelet.config.k8s.io/v1beta1
209+
kind: KubeletConfiguration
202210
featureGates:
203211
KubeletInUserNamespace: true
204212
# We use cgroupfs that is delegated by systemd, so we do not use "systemd" driver
205213
# (unless you run another systemd in the namespace)
206214
cgroupDriver: "cgroupfs"
207215
```
208216
209-
When the `KubeletInUserNamespace` feature gate is enabled, kubelet ignores errors that may happen during setting the following sysctl values:
217+
When the `KubeletInUserNamespace` feature gate is enabled, the kubelet ignores errors
218+
that may happen during setting the following sysctl values on the node.
219+
210220
- `vm.overcommit_memory`
211221
- `vm.panic_on_oom`
212222
- `kernel.panic`
213223
- `kernel.panic_on_oops`
214224
- `kernel.keys.root_maxkeys`
215225
- `kernel.keys.root_maxbytes`.
216-
(these are sysctl values for the host, not for the containers).
217226

218227
Within a user namespace, the kubelet also ignores any error raised from trying to open `/dev/kmsg`.
219228
This feature gate also allows kube-proxy to ignore an error during setting `RLIMIT_NOFILE`.
220229

221230
The `KubeletInUserNamespace` feature gate was introduced in Kubernetes v1.22 with "alpha" status.
222231

223-
Running kubelet in a user namespace without using this feature gate is also possible by mounting a specially crafted proc filesystem,
224-
but not officially supported.
232+
Running kubelet in a user namespace without using this feature gate is also possible
233+
by mounting a specially crafted proc filesystem, but not officially supported.
225234

226235
### Configuring kube-proxy
227236

@@ -251,9 +260,11 @@ For more on this, see the [Caveats and Future work](https://rootlesscontaine.rs/
251260
on the rootlesscontaine.rs website.
252261

253262
## {{% heading "seealso" %}}
263+
254264
- [rootlesscontaine.rs](https://rootlesscontaine.rs/)
255265
- [Rootless Containers 2020 (KubeCon NA 2020)](https://www.slideshare.net/AkihiroSuda/kubecon-na-2020-containerd-rootless-containers-2020)
256266
- [Running kind with Rootless Docker](https://kind.sigs.k8s.io/docs/user/rootless/)
257267
- [Usernetes](https://github.com/rootless-containers/usernetes)
258268
- [Running K3s with rootless mode](https://rancher.com/docs/k3s/latest/en/advanced/#running-k3s-with-rootless-mode-experimental)
259269
- [KEP-2033: Kubelet-in-UserNS (aka Rootless mode)](https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/2033-kubelet-in-userns-aka-rootless)
270+

0 commit comments

Comments
 (0)