Skip to content

Commit 102116e

Browse files
author
朱正浩,Zhu Zhenghao
committed
sync page user-namespaces, sysctl-cluster
1 parent e813b58 commit 102116e

File tree

3 files changed

+62
-40
lines changed

3 files changed

+62
-40
lines changed

content/zh-cn/docs/concepts/workloads/pods/user-namespaces.md

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -48,35 +48,39 @@ mitigate some future vulnerabilities too.
4848
<!-- body -->
4949
## {{% heading "prerequisites" %}}
5050

51-
{{% thirdparty-content single="true" %}}
52-
<!-- if adding another runtime in the future, omit the single setting -->
51+
{{% thirdparty-content %}}
5352

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. -->
5455
<!--
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
5657
{{< glossary_tooltip text="container runtime" term_id="container-runtime" >}}
5758
to use this feature with Kubernetes stateless pods:
5859
59-
* CRI-O: v1.25 has support for user namespaces.
60+
* CRI-O: version 1.25 (and later) supports user namespaces for containers.
6061
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.
6366
6467
Support for this in [cri-dockerd is not planned][CRI-dockerd-issue] yet.
6568
-->
6669

6770
这是一个只对 Linux 有效的功能特性。此外,需要在{{< glossary_tooltip text="容器运行时" term_id="container-runtime" >}}提供支持,
6871
才能在 Kubernetes 无状态 Pod 中使用这一功能:
6972

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 版本的文档。
7276

7377
目前 [cri-dockerd 没有计划][CRI-dockerd-issue]支持此功能。
7478

7579
[CRI-dockerd-issue]: https://github.com/Mirantis/cri-dockerd/issues/74
7680
[containerd-userns-issue]: https://github.com/containerd/containerd/issues/7063
7781

78-
<!--
79-
## Introduction
82+
<!--
83+
## Introduction
8084
-->
8185
## 介绍 {#introduction}
8286

@@ -126,8 +130,8 @@ if user namespaces is activated.
126130
大多数需要以 root 身份运行但不访问其他主机命名空间或资源的应用程序,
127131
在用户命名空间被启用时,应该可以继续正常运行,不需要做任何改变。
128132

129-
<!--
130-
## Understanding user namespaces for stateless pods
133+
<!--
134+
## Understanding user namespaces for stateless pods
131135
-->
132136
## 了解无状态 Pod 的用户命名空间 {#understanding-user-namespaces-for-stateless-pods}
133137

@@ -190,8 +194,8 @@ of it.
190194
授予一个 Pod 的权能也被限制在 Pod 的用户命名空间内,
191195
并且在这一命名空间之外大多无效,有些甚至完全无效。这里有两个例子:
192196

193-
- `CAP_SYS_MODULE` 若被授予一个使用用户命名空间的 Pod 则没有任何效果,这个 Pod 不能加载内核模块。
194-
- `CAP_SYS_ADMIN` 只限于 Pod 所在的用户命名空间,在该命名空间之外无效。
197+
- `CAP_SYS_MODULE` 若被授予一个使用用户命名空间的 Pod 则没有任何效果,这个 Pod 不能加载内核模块。
198+
- `CAP_SYS_ADMIN` 只限于 Pod 所在的用户命名空间,在该命名空间之外无效。
195199

196200
<!--
197201
Without using a user namespace a container running as root, in the case of a
@@ -235,14 +239,15 @@ kubelet 会把高于这个范围的 UID/GID 分配给 Pod。
235239
请注意,这个建议对减轻 [CVE-2021-25741][CVE-2021-25741] 等 CVE 的影响很重要;
236240
在这些 CVE 中,Pod 有可能读取主机中的任意文件。
237241
如果 Pod 和主机的 UID/GID 不重叠,Pod 能够做的事情就会受到限制:
238-
Pod的 UID/GID 不会与主机的文件所有者/组相匹配。
242+
Pod 的 UID/GID 不会与主机的文件所有者/组相匹配。
239243

240244
[CVE-2021-25741]: https://github.com/kubernetes/kubernetes/issues/104980
241245

242-
<!--
243-
# Limitations
246+
<!--
247+
## Limitations
244248
-->
245249
## 限制 {#limitations}
250+
246251
<!--
247252
When using a user namespace for the pod, it is disallowed to use other host
248253
namespaces. In particular, if you set `hostUsers: false` then you are not
@@ -255,9 +260,9 @@ allowed to set any of:
255260
当 Pod 使用用户命名空间时,不允许 Pod 使用其他主机命名空间。
256261
特别是,如果你设置了 `hostUsers: false`,那么你就不可以设置如下属性:
257262

258-
* `hostNetwork: true`
259-
* `hostIPC: true`
260-
* `hostPID: true`
263+
* `hostNetwork: true`
264+
* `hostIPC: true`
265+
* `hostPID: true`
261266

262267
<!--
263268
The pod is allowed to use no volumes at all or, if using volumes, only these
@@ -269,15 +274,16 @@ volume types are allowed:
269274
* downwardAPI
270275
* emptyDir
271276
-->
277+
272278
Pod 完全不使用卷是被允许的;如果使用卷,只允许使用以下卷类型:
273279

274-
* configmap
275-
* secret
276-
* projected
277-
* downwardAPI
278-
* emptyDir
280+
* configmap
281+
* secret
282+
* projected
283+
* downwardAPI
284+
* emptyDir
279285

280-
<!--
286+
<!--
281287
To guarantee that the pod can read the files of such volumes, volumes are
282288
created as if you specified `.spec.securityContext.fsGroup` as `0` for the Pod.
283289
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
287293
permissions for the group, even if `defaultMode` or `mode` to specific items of
288294
the volumes were specified without permissions to groups. For example, it is not
289295
possible to mount these volumes in a way that its files have permissions only
290-
for the owner.
296+
for the owner.
291297
-->
292298
为了保证 Pod 可以读取这些卷中的文件,卷的创建操作就像你为 Pod 指定了 `.spec.securityContext.fsGroup``0` 一样。
293299
如果该属性被设定为不同值,那么这个不同值当然也会被使用。
294300

295301
作为一个副产品,这些卷的文件夹和文件将具有所给组的权限,
296302
即使 `defaultMode` 或 volumes 的特定项目的 `mode` 被指定为没有组的权限。
297-
例如,不可以在挂载这些卷时使其文件只允许所有者访问。
303+
例如,不可以在挂载这些卷时使其文件只允许所有者访问。

content/zh-cn/docs/tasks/administer-cluster/sysctl-cluster.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ the Linux man-pages project.
4444

4545
## {{% heading "prerequisites" %}}
4646

47+
{{< note >}}
48+
<!--
49+
`sysctl` is a Linux-specific command-line tool used to configure various kernel parameters
50+
and it is not available on non-Linux operating systems.
51+
-->
52+
`sysctl` 是一个 Linux 特有的命令行工具,用于配置各种内核参数,
53+
它在非 Linux 操作系统上无法使用。
54+
{{< /note >}}
55+
4756
{{< include "task-tutorial-prereqs.md" >}}
4857

4958
<!--
@@ -119,17 +128,17 @@ The following sysctls are supported in the _safe_ set:
119128
至今为止,大多数 **有命名空间的** sysctl 参数不一定被认为是 **安全** 的。
120129
以下几种 sysctl 参数是 **安全的**
121130

122-
- `kernel.shm_rmid_forced`
123-
- `net.ipv4.ip_local_port_range`
124-
- `net.ipv4.tcp_syncookies`
125-
- `net.ipv4.ping_group_range`(从 Kubernetes 1.18 开始)
131+
- `kernel.shm_rmid_forced`,
132+
- `net.ipv4.ip_local_port_range`,
133+
- `net.ipv4.tcp_syncookies`,
134+
- `net.ipv4.ping_group_range`(从 Kubernetes 1.18 开始),
126135
- `net.ipv4.ip_unprivileged_port_start`(从 Kubernetes 1.22 开始)。
127136

128137
{{< note >}}
129138
<!--
130139
The example `net.ipv4.tcp_syncookies` is not namespaced on Linux kernel version 4.4 or lower.
131140
-->
132-
示例中的 `net.ipv4.tcp_syncookies` 在Linux 内核 4.4 或更低的版本中是无命名空间的。
141+
示例中的 `net.ipv4.tcp_syncookies` 在 Linux 内核 4.4 或更低的版本中是无命名空间的。
133142
{{< /note >}}
134143

135144
<!--
@@ -236,7 +245,7 @@ securityContext 应用于同一个 Pod 中的所有容器。
236245
<!--
237246
This example uses the pod securityContext to set a safe sysctl
238247
`kernel.shm_rmid_forced` and two unsafe sysctls `net.core.somaxconn` and
239-
`kernel.msgmax` There is no distinction between _safe_ and _unsafe_ sysctls in
248+
`kernel.msgmax`. There is no distinction between _safe_ and _unsafe_ sysctls in
240249
the specification.
241250
-->
242251
此示例中,使用 Pod SecurityContext 来对一个安全的 sysctl 参数

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,23 @@ this is true when user namespaces are used.
7575
* 特性 `UserNamespacesStatelessPodsSupport` 需要被启用。
7676

7777
<!--
78-
In addition, support is needed in the
79-
{{< glossary_tooltip text="container runtime" term_id="container-runtime" >}}
80-
to use this feature with Kubernetes stateless pods:
78+
The cluster that you're using **must** include at least one node that meets the
79+
[requirements](/docs/concepts/workloads/pods/user-namespaces/#before-you-begin)
80+
for using user namespaces with Pods.
8181
-->
82-
此外, 需要{{< glossary_tooltip text="容器运行时" term_id="container-runtime" >}}提供相应的支持,
83-
才能将此特性与 Kubernetes 无状态 Pod 一起使用:
82+
你所使用的集群**必须**包括至少一个符合
83+
[要求](/zh-cn/docs/concepts/workloads/pods/user-namespaces/#before-you-begin)
84+
的节点,以便为 Pod 配置用户名字空间。
8485

8586
<!--
86-
* CRI-O: v1.25 has support for user namespaces.
87+
If you have a mixture of nodes and only some of the nodes provide user namespace support for
88+
Pods, you also need to ensure that the user namespace Pods are
89+
[scheduled](/docs/concepts/scheduling-eviction/assign-pod-node/) to suitable nodes.
8790
-->
91+
如果你有混合节点,并且只有部分节点支持为 Pod 配置用户名字空间,
92+
你还需要确保配置了用户名字空间的 Pod
93+
[调度](/zh-cn/docs/concepts/scheduling-eviction/assign-pod-node/)到合适的节点。
94+
8895
* CRI-O: v1.25 支持用户名字空间。
8996

9097
<!--

0 commit comments

Comments
 (0)