Skip to content

Commit 49fa5ba

Browse files
authored
Merge pull request #50329 from my-git9/np-24976
[zh-cn]sync assign-pod-node topology-spread-constraints user-namespaces
2 parents 9055025 + bb34351 commit 49fa5ba

File tree

3 files changed

+68
-40
lines changed

3 files changed

+68
-40
lines changed

content/zh-cn/docs/concepts/scheduling-eviction/assign-pod-node.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ in the [scheduler configuration](/docs/reference/scheduling/config/). For exampl
376376
`args` 字段添加 `addedAffinity`。例如:
377377

378378
```yaml
379-
apiVersion: kubescheduler.config.k8s.io/v1beta3
379+
apiVersion: kubescheduler.config.k8s.io/v1
380380
kind: KubeSchedulerConfiguration
381381

382382
profiles:
@@ -730,9 +730,31 @@ to the same revision as the incoming Pod, so that a rolling upgrade won't break
730730
确保滚动升级不会破坏亲和性。
731731

732732
<!--
733-
# Only Pods from a given rollout are taken into consideration when calculating pod affinity.
734-
# If you update the Deployment, the replacement Pods follow their own affinity rules
735-
# (if there are any defined in the new Pod template)
733+
```yaml
734+
apiVersion: apps/v1
735+
kind: Deployment
736+
metadata:
737+
name: application-server
738+
...
739+
spec:
740+
template:
741+
spec:
742+
affinity:
743+
podAffinity:
744+
requiredDuringSchedulingIgnoredDuringExecution:
745+
- labelSelector:
746+
matchExpressions:
747+
- key: app
748+
operator: In
749+
values:
750+
- database
751+
topologyKey: topology.kubernetes.io/zone
752+
# Only Pods from a given rollout are taken into consideration when calculating pod affinity.
753+
# If you update the Deployment, the replacement Pods follow their own affinity rules
754+
# (if there are any defined in the new Pod template)
755+
matchLabelKeys:
756+
- pod-template-hash
757+
```
736758
-->
737759
```yaml
738760
apiVersion: apps/v1

content/zh-cn/docs/concepts/scheduling-eviction/topology-spread-constraints.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ or configure topology spread constraints for individual workloads.
2626
例如区域(Region)、可用区(Zone)、节点和其他用户自定义拓扑域。
2727
这样做有助于实现高可用并提升资源利用率。
2828

29-
你可以将[集群级约束](#cluster-level-default-constraints)设为默认值,或为个别工作负载配置拓扑分布约束。
29+
你可以将[集群级约束](#cluster-level-default-constraints)设为默认值,
30+
或为个别工作负载配置拓扑分布约束。
3031

3132
<!-- body -->
3233

@@ -62,19 +63,20 @@ are split across three different datacenters (or infrastructure zones). Now you
6263
have less concern about a single node failure, but you notice that latency is
6364
higher than you'd like, and you are paying for network costs associated with
6465
sending network traffic between the different zones.
65-
66-
You decide that under normal operation you'd prefer to have a similar number of replicas
67-
[scheduled](/docs/concepts/scheduling-eviction/) into each infrastructure zone,
68-
and you'd like the cluster to self-heal in the case that there is a problem.
69-
70-
Pod topology spread constraints offer you a declarative way to configure that.
7166
-->
7267
随着你的工作负载扩容,运行的 Pod 变多,将需要考虑另一个重要问题。
7368
假设你有 3 个节点,每个节点运行 5 个 Pod。这些节点有足够的容量能够运行许多副本;
7469
但与这个工作负载互动的客户端分散在三个不同的数据中心(或基础设施可用区)。
7570
现在你可能不太关注单节点故障问题,但你会注意到延迟高于自己的预期,
7671
在不同的可用区之间发送网络流量会产生一些网络成本。
7772

73+
<!--
74+
You decide that under normal operation you'd prefer to have a similar number of replicas
75+
[scheduled](/docs/concepts/scheduling-eviction/) into each infrastructure zone,
76+
and you'd like the cluster to self-heal in the case that there is a problem.
77+
78+
Pod topology spread constraints offer you a declarative way to configure that.
79+
-->
7880
你决定在正常运营时倾向于将类似数量的副本[调度](/zh-cn/docs/concepts/scheduling-eviction/)
7981
到每个基础设施可用区,且你想要该集群在遇到问题时能够自愈。
8082

@@ -221,7 +223,13 @@ your cluster. Those fields are:
221223
will try to put a balanced number of pods into each domain.
222224
Also, we define an eligible domain as a domain whose nodes meet the requirements of
223225
nodeAffinityPolicy and nodeTaintsPolicy.
226+
-->
227+
- **topologyKey**[节点标签](#node-labels)的键。如果节点使用此键标记并且具有相同的标签值,
228+
则将这些节点视为处于同一拓扑域中。我们将拓扑域中(即键值对)的每个实例称为一个域。
229+
调度器将尝试在每个拓扑域中放置数量均衡的 Pod。
230+
另外,我们将符合条件的域定义为其节点满足 nodeAffinityPolicy 和 nodeTaintsPolicy 要求的域。
224231

232+
<!--
225233
- **whenUnsatisfiable** indicates how to deal with a Pod if it doesn't satisfy the spread constraint:
226234
- `DoNotSchedule` (default) tells the scheduler not to schedule it.
227235
- `ScheduleAnyway` tells the scheduler to still schedule it while prioritizing nodes that minimize the skew.
@@ -232,11 +240,6 @@ your cluster. Those fields are:
232240
See [Label Selectors](/docs/concepts/overview/working-with-objects/labels/#label-selectors)
233241
for more details.
234242
-->
235-
- **topologyKey**[节点标签](#node-labels)的键。如果节点使用此键标记并且具有相同的标签值,
236-
则将这些节点视为处于同一拓扑域中。我们将拓扑域中(即键值对)的每个实例称为一个域。
237-
调度器将尝试在每个拓扑域中放置数量均衡的 Pod。
238-
另外,我们将符合条件的域定义为其节点满足 nodeAffinityPolicy 和 nodeTaintsPolicy 要求的域。
239-
240243
- **whenUnsatisfiable** 指示如果 Pod 不满足分布约束时如何处理:
241244
- `DoNotSchedule`(默认)告诉调度器不要调度。
242245
- `ScheduleAnyway` 告诉调度器仍然继续调度,只是根据如何能将偏差最小化来对节点进行排序。
@@ -434,12 +437,6 @@ Usually, if you are using a workload controller such as a Deployment, the pod te
434437
takes care of this for you. If you mix different spread constraints then Kubernetes
435438
follows the API definition of the field; however, the behavior is more likely to become
436439
confusing and troubleshooting is less straightforward.
437-
438-
You need a mechanism to ensure that all the nodes in a topology domain (such as a
439-
cloud provider region) are labelled consistently.
440-
To avoid you needing to manually label nodes, most clusters automatically
441-
populate well-known labels such as `kubernetes.io/hostname`. Check whether
442-
your cluster supports this.
443440
-->
444441
## 一致性 {#Consistency}
445442
@@ -449,6 +446,13 @@ your cluster supports this.
449446
如果你混合不同的分布约束,则 Kubernetes 会遵循该字段的 API 定义;
450447
但是,该行为可能更令人困惑,并且故障排除也没那么简单。
451448
449+
<!--
450+
You need a mechanism to ensure that all the nodes in a topology domain (such as a
451+
cloud provider region) are labelled consistently.
452+
To avoid you needing to manually label nodes, most clusters automatically
453+
populate well-known labels such as `kubernetes.io/hostname`. Check whether
454+
your cluster supports this.
455+
-->
452456
你需要一种机制来确保拓扑域(例如云提供商区域)中的所有节点具有一致的标签。
453457
为了避免你需要手动为节点打标签,大多数集群会自动填充知名的标签,
454458
例如 `kubernetes.io/hostname`。检查你的集群是否支持此功能。
@@ -822,7 +826,7 @@ An example configuration might look like follows:
822826
配置的示例可能看起来像下面这个样子:
823827
824828
```yaml
825-
apiVersion: kubescheduler.config.k8s.io/v1beta3
829+
apiVersion: kubescheduler.config.k8s.io/v1
826830
kind: KubeSchedulerConfiguration
827831
828832
profiles:
@@ -894,7 +898,7 @@ empty `defaultConstraints` in the `PodTopologySpread` plugin configuration:
894898
并将 `PodTopologySpread` 插件配置中的 `defaultConstraints` 参数置空来禁用默认 Pod 分布约束:
895899

896900
```yaml
897-
apiVersion: kubescheduler.config.k8s.io/v1beta3
901+
apiVersion: kubescheduler.config.k8s.io/v1
898902
kind: KubeSchedulerConfiguration
899903
900904
profiles:

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

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace.
2727
本页解释了在 Kubernetes Pod 中如何使用用户命名空间。
2828
用户命名空间将容器内运行的用户与主机中的用户隔离开来。
2929

30-
在容器中以 root 身份运行的进程可以在主机中以不同的(非 root)用户身份运行;
30+
在容器中以 Root 身份运行的进程可以在主机中以不同的(非 Root)用户身份运行;
3131
换句话说,该进程在用户命名空间内的操作具有完全的权限,
3232
但在命名空间外的操作是无特权的。
3333

@@ -39,13 +39,14 @@ exploitable when user namespaces is active. It is expected user namespace will
3939
mitigate some future vulnerabilities too.
4040
-->
4141
你可以使用这个功能来减少被破坏的容器对主机或同一节点中的其他 Pod 的破坏。
42-
[几个安全漏洞][KEP-vulns]被评为 ******重要**
42+
[几个安全漏洞][KEP-vulns]被评为 **(HIGH)****重要(CRITICAL)**
4343
当用户命名空间处于激活状态时,这些漏洞是无法被利用的。
4444
预计用户命名空间也会减轻一些未来的漏洞。
4545

4646
[KEP-vulns]: https://github.com/kubernetes/enhancements/tree/217d790720c5aef09b8bd4d6ca96284a0affe6c2/keps/sig-node/127-user-namespaces#motivation
4747

4848
<!-- body -->
49+
4950
## {{% heading "prerequisites" %}}
5051

5152
{{% thirdparty-content %}}
@@ -57,7 +58,15 @@ the filesystems used. This means:
5758
* On the node, the filesystem you use for `/var/lib/kubelet/pods/`, or the
5859
custom directory you configure for this, needs idmap mount support.
5960
* All the filesystems used in the pod's volumes must support idmap mounts.
61+
-->
62+
这是一个只对 Linux 有效的功能特性,且需要 Linux 支持在所用文件系统上挂载 idmap。
63+
这意味着:
64+
65+
* 在节点上,你用于 `/var/lib/kubelet/pods/` 的文件系统,或你为此配置的自定义目录,
66+
需要支持 idmap 挂载。
67+
* Pod 卷中使用的所有文件系统都必须支持 idmap 挂载。
6068

69+
<!--
6170
In practice this means you need at least Linux 6.3, as tmpfs started supporting
6271
idmap mounts in that version. This is usually needed as several Kubernetes
6372
features use tmpfs (the service account token that is mounted by default uses a
@@ -66,13 +75,6 @@ tmpfs, Secrets use a tmpfs, etc.)
6675
Some popular filesystems that support idmap mounts in Linux 6.3 are: btrfs,
6776
ext4, xfs, fat, tmpfs, overlayfs.
6877
-->
69-
这是一个只对 Linux 有效的功能特性,且需要 Linux 支持在所用文件系统上挂载 idmap。
70-
这意味着:
71-
72-
* 在节点上,你用于 `/var/lib/kubelet/pods/` 的文件系统,或你为此配置的自定义目录,
73-
需要支持 idmap 挂载。
74-
* Pod 卷中使用的所有文件系统都必须支持 idmap 挂载。
75-
7678
在实践中,这意味着你最低需要 Linux 6.3,因为 tmpfs 在该版本中开始支持 idmap 挂载。
7779
这通常是需要的,因为有几个 Kubernetes 功能特性使用 tmpfs
7880
(默认情况下挂载的服务账号令牌使用 tmpfs、Secret 使用 tmpfs 等等)。
@@ -116,14 +118,14 @@ To use user namespaces with Kubernetes, you also need to use a CRI
116118
此外,需要在{{< glossary_tooltip text="容器运行时" term_id="container-runtime" >}}提供支持,
117119
才能在 Kubernetes Pod 中使用这一功能:
118120

119-
* containerd:2.0(及更高版本)支持容器使用用户命名空间
121+
* containerd:2.0(及更高)版本支持容器使用用户命名空间
120122
* CRI-O:1.25(及更高)版本支持配置容器的用户命名空间。
121123

122124
<!--
123125
You can see the status of user namespaces support in cri-dockerd tracked in an [issue][CRI-dockerd-issue]
124126
on GitHub.
125127
-->
126-
你可以在 GitHub 上的 [issue][CRI-dockerd-issue] 中查看 cri-dockerd
128+
你可以在 GitHub 上的 [Issue][CRI-dockerd-issue] 中查看 cri-dockerd
127129
中用户命名空间支持的状态。
128130

129131
<!--
@@ -195,7 +197,7 @@ if user namespaces is activated.
195197
通常是 65534(配置在 `/proc/sys/kernel/overflowuid和/proc/sys/kernel/overflowgid`)。
196198
然而,即使以 65534 用户/组的身份运行,也不可能修改这些文件。
197199

198-
大多数需要以 root 身份运行但不访问其他主机命名空间或资源的应用程序,
200+
大多数需要以 Root 身份运行但不访问其他主机命名空间或资源的应用程序,
199201
在用户命名空间被启用时,应该可以继续正常运行,不需要做任何改变。
200202

201203
<!--
@@ -236,8 +238,8 @@ This abstraction limits what can happen, for example, if the container manages
236238
to escape to the host. Given that the container is running as a non-privileged
237239
user on the host, it is limited what it can do to the host.
238240
-->
239-
这意味着容器可以以 root 身份运行,并将该身份映射到主机上的一个非 root 用户。
240-
在容器内,进程会认为它是以 root 身份运行的(因此像 `apt``yum` 等工具可以正常工作),
241+
这意味着容器可以以 Root 身份运行,并将该身份映射到主机上的一个非 Root 用户。
242+
在容器内,进程会认为它是以 Root 身份运行的(因此像 `apt``yum` 等工具可以正常工作),
241243
而实际上该进程在主机上没有权限。
242244
你可以验证这一点,例如,如果你从主机上执行 `ps aux` 来检查容器进程是以哪个用户运行的。
243245
`ps` 显示的用户与你在容器内执行 `id` 命令时看到的用户是不一样的。
@@ -274,7 +276,7 @@ this is true when we use user namespaces.
274276
If you want to know more details about what changes when user namespaces are in
275277
use, see `man 7 user_namespaces`.
276278
-->
277-
在不使用用户命名空间的情况下,以 root 账号运行的容器,在容器逃逸时,在节点上有 root 权限。
279+
在不使用用户命名空间的情况下,以 Root 账号运行的容器,在容器逃逸时,在节点上有 Root 权限。
278280
而且如果某些权能被授予了某容器,这些权能在宿主机上也是有效的。
279281
当我们使用用户命名空间时,这些都不再成立。
280282

@@ -435,7 +437,7 @@ privileged user on the host. Here's the list of fields that are **not** checks f
435437
circumstances:
436438
-->
437439
如果你启用相关特性门控并创建了使用用户命名空间的 Pod,以下的字段不会被限制,
438-
即使在执行了 _Baseline__Restricted_ Pod 安全性标准的上下文中。这种行为不会带来安全问题,
440+
即使在执行了 **Baseline****Restricted** Pod 安全性标准的上下文中。这种行为不会带来安全问题,
439441
因为带有用户命名空间的 Pod 内的 `root` 实际上指的是容器内的用户,绝不会映射到主机上的特权用户。
440442
以下是在这种情况下**不进行**检查的 Pod 字段列表:
441443

0 commit comments

Comments
 (0)