@@ -48,35 +48,39 @@ mitigate some future vulnerabilities too.
48
48
<!-- body -->
49
49
## {{% heading "prerequisites" %}}
50
50
51
- {{% thirdparty-content single="true" %}}
52
- <!-- if adding another runtime in the future, omit the single setting -->
51
+ {{% thirdparty-content %}}
53
52
53
+ <!-- When merging this with the dev-1.27 branch conflicts will arise. The text
54
+ as it is in the dev-1.27 branch should be used. -->
54
55
<!--
55
- This is a Linux only feature. In addition, support is needed in the
56
+ This is a Linux only feature. In addition, support is needed in the
56
57
{{< glossary_tooltip text="container runtime" term_id="container-runtime" >}}
57
58
to use this feature with Kubernetes stateless pods:
58
59
59
- * CRI-O: v1 .25 has support for user namespaces.
60
+ * CRI-O: version 1 .25 (and later) supports user namespaces for containers .
60
61
61
- * containerd: support is planned for the 1.7 release. See containerd
62
- issue [#7063][containerd-userns-issue] for more details.
62
+ * containerd: version 1.7 supports user namespaces for containers, compatible
63
+ with Kubernetes v1.25 and v1.26, but not with later releases. If you are
64
+ running a different version of Kubernetes, check the documentation for that
65
+ Kubernetes release.
63
66
64
67
Support for this in [cri-dockerd is not planned][CRI-dockerd-issue] yet.
65
68
-->
66
69
67
70
这是一个只对 Linux 有效的功能特性。此外,需要在{{< glossary_tooltip text="容器运行时" term_id="container-runtime" >}}提供支持,
68
71
才能在 Kubernetes 无状态 Pod 中使用这一功能:
69
72
70
- * CRI-O:v1.25 版已经支持用户命名空间。
71
- * containerd:计划在 1.7 版本中支持。更多细节请参见 containerd 问题 [ #7063 ] [ containerd-userns-issue ] 。
73
+ * CRI-O:1.25(及更高)版本支持配置容器的用户命名空间。
74
+ * containerd:1.7 版本支持配置容器的用户命名空间,兼容 Kubernetes v1.25 和 v1.26,但不兼容更高版本。
75
+ 如果你运行的是不同版本的 Kubernetes,请查看该 Kubernetes 版本的文档。
72
76
73
77
目前 [ cri-dockerd 没有计划] [ CRI-dockerd-issue ] 支持此功能。
74
78
75
79
[ CRI-dockerd-issue ] : https://github.com/Mirantis/cri-dockerd/issues/74
76
80
[ containerd-userns-issue ] : https://github.com/containerd/containerd/issues/7063
77
81
78
- <!--
79
- ## Introduction
82
+ <!--
83
+ ## Introduction
80
84
-->
81
85
## 介绍 {#introduction}
82
86
@@ -126,8 +130,8 @@ if user namespaces is activated.
126
130
大多数需要以 root 身份运行但不访问其他主机命名空间或资源的应用程序,
127
131
在用户命名空间被启用时,应该可以继续正常运行,不需要做任何改变。
128
132
129
- <!--
130
- ## Understanding user namespaces for stateless pods
133
+ <!--
134
+ ## Understanding user namespaces for stateless pods
131
135
-->
132
136
## 了解无状态 Pod 的用户命名空间 {#understanding-user-namespaces-for-stateless-pods}
133
137
@@ -190,8 +194,8 @@ of it.
190
194
授予一个 Pod 的权能也被限制在 Pod 的用户命名空间内,
191
195
并且在这一命名空间之外大多无效,有些甚至完全无效。这里有两个例子:
192
196
193
- - ` CAP_SYS_MODULE ` 若被授予一个使用用户命名空间的 Pod 则没有任何效果,这个 Pod 不能加载内核模块。
194
- - ` CAP_SYS_ADMIN ` 只限于 Pod 所在的用户命名空间,在该命名空间之外无效。
197
+ - ` CAP_SYS_MODULE ` 若被授予一个使用用户命名空间的 Pod 则没有任何效果,这个 Pod 不能加载内核模块。
198
+ - ` CAP_SYS_ADMIN ` 只限于 Pod 所在的用户命名空间,在该命名空间之外无效。
195
199
196
200
<!--
197
201
Without using a user namespace a container running as root, in the case of a
@@ -235,14 +239,15 @@ kubelet 会把高于这个范围的 UID/GID 分配给 Pod。
235
239
请注意,这个建议对减轻 [ CVE-2021 -25741] [ CVE-2021-25741 ] 等 CVE 的影响很重要;
236
240
在这些 CVE 中,Pod 有可能读取主机中的任意文件。
237
241
如果 Pod 和主机的 UID/GID 不重叠,Pod 能够做的事情就会受到限制:
238
- Pod的 UID/GID 不会与主机的文件所有者/组相匹配。
242
+ Pod 的 UID/GID 不会与主机的文件所有者/组相匹配。
239
243
240
244
[ CVE-2021-25741 ] : https://github.com/kubernetes/kubernetes/issues/104980
241
245
242
- <!--
243
- # Limitations
246
+ <!--
247
+ ## Limitations
244
248
-->
245
249
## 限制 {#limitations}
250
+
246
251
<!--
247
252
When using a user namespace for the pod, it is disallowed to use other host
248
253
namespaces. In particular, if you set `hostUsers: false` then you are not
@@ -255,9 +260,9 @@ allowed to set any of:
255
260
当 Pod 使用用户命名空间时,不允许 Pod 使用其他主机命名空间。
256
261
特别是,如果你设置了 ` hostUsers: false ` ,那么你就不可以设置如下属性:
257
262
258
- * ` hostNetwork: true `
259
- * ` hostIPC: true `
260
- * ` hostPID: true `
263
+ * ` hostNetwork: true `
264
+ * ` hostIPC: true `
265
+ * ` hostPID: true `
261
266
262
267
<!--
263
268
The pod is allowed to use no volumes at all or, if using volumes, only these
@@ -269,15 +274,16 @@ volume types are allowed:
269
274
* downwardAPI
270
275
* emptyDir
271
276
-->
277
+
272
278
Pod 完全不使用卷是被允许的;如果使用卷,只允许使用以下卷类型:
273
279
274
- * configmap
275
- * secret
276
- * projected
277
- * downwardAPI
278
- * emptyDir
280
+ * configmap
281
+ * secret
282
+ * projected
283
+ * downwardAPI
284
+ * emptyDir
279
285
280
- <!--
286
+ <!--
281
287
To guarantee that the pod can read the files of such volumes, volumes are
282
288
created as if you specified `.spec.securityContext.fsGroup` as `0` for the Pod.
283
289
If it is specified to a different value, this other value will of course be
@@ -287,11 +293,11 @@ As a by-product of this, folders and files for these volumes will have
287
293
permissions for the group, even if `defaultMode` or `mode` to specific items of
288
294
the volumes were specified without permissions to groups. For example, it is not
289
295
possible to mount these volumes in a way that its files have permissions only
290
- for the owner.
296
+ for the owner.
291
297
-->
292
298
为了保证 Pod 可以读取这些卷中的文件,卷的创建操作就像你为 Pod 指定了 ` .spec.securityContext.fsGroup ` 为 ` 0 ` 一样。
293
299
如果该属性被设定为不同值,那么这个不同值当然也会被使用。
294
300
295
301
作为一个副产品,这些卷的文件夹和文件将具有所给组的权限,
296
302
即使 ` defaultMode ` 或 volumes 的特定项目的 ` mode ` 被指定为没有组的权限。
297
- 例如,不可以在挂载这些卷时使其文件只允许所有者访问。
303
+ 例如,不可以在挂载这些卷时使其文件只允许所有者访问。
0 commit comments