Skip to content

Commit 1873414

Browse files
authored
Merge pull request #46218 from rata/rata/userns-1.29-backports
[release-1.29]: Fix userns example and add OCI runtime requirements
2 parents 99a1995 + 38c92e7 commit 1873414

File tree

2 files changed

+44
-10
lines changed

2 files changed

+44
-10
lines changed

content/en/docs/concepts/workloads/pods/user-namespaces.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,26 @@ tmpfs, Secrets use a tmpfs, etc.)
4646
Some popular filesystems that support idmap mounts in Linux 6.3 are: btrfs,
4747
ext4, xfs, fat, tmpfs, overlayfs.
4848

49-
In addition, support is needed in the
49+
In addition, the container runtime and its underlying OCI runtime must support
50+
user namespaces. The following OCI runtimes offer support:
51+
52+
* [crun](https://github.com/containers/crun) version 1.9 or greater (it's recommend version 1.13+).
53+
54+
<!-- ideally, update this if a newer minor release of runc comes out, whether or not it includes the idmap support -->
55+
{{< note >}}
56+
Many OCI runtimes do not include the support needed for using user namespaces in
57+
Linux pods. If you use a managed Kubernetes, or have downloaded it from packages
58+
and set it up, it's likely that nodes in your cluster use a runtime that doesn't
59+
include this support. For example, the most widely used OCI runtime is `runc`,
60+
and version `1.1.z` of runc doesn't support all the features needed by the
61+
Kubernetes implementation of user namespaces.
62+
63+
If there is a newer release of runc than 1.1 available for use, check its
64+
documentation and release notes for compatibility (look for idmap mounts support
65+
in particular, because that is the missing feature).
66+
{{< /note >}}
67+
68+
To use user namespaces with Kubernetes, you also need to use a CRI
5069
{{< glossary_tooltip text="container runtime" term_id="container-runtime" >}}
5170
to use this feature with Kubernetes pods:
5271

content/en/docs/tasks/configure-pod-container/user-namespaces.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,27 +82,42 @@ to `false`. For example:
8282
kubectl attach -it userns bash
8383
```
8484

85-
And run the command. The output is similar to this:
85+
Run this command:
8686

87-
```none
87+
```shell
8888
readlink /proc/self/ns/user
89+
```
90+
91+
The output is similar to:
92+
93+
```shell
8994
user:[4026531837]
95+
```
96+
97+
Also run:
98+
99+
```shell
90100
cat /proc/self/uid_map
91-
0 0 4294967295
92101
```
93102

94-
Then, open a shell in the host and run the same command.
103+
The output is similar to:
104+
```shell
105+
0 833617920 65536
106+
```
107+
108+
Then, open a shell in the host and run the same commands.
109+
110+
The `readlink` command shows the user namespace the process is running in. It
111+
should be different when it is run on the host and inside the container.
95112

96-
The output must be different. This means the host and the pod are using a
97-
different user namespace. When user namespaces are not enabled, the host and the
98-
pod use the same user namespace.
113+
The last number of the `uid_map` file inside the container must be 65536, on the
114+
host it must be a bigger number.
99115

100116
If you are running the kubelet inside a user namespace, you need to compare the
101117
output from running the command in the pod to the output of running in the host:
102118

103-
```none
119+
```shell
104120
readlink /proc/$pid/ns/user
105-
user:[4026534732]
106121
```
107122

108123
replacing `$pid` with the kubelet PID.

0 commit comments

Comments
 (0)