Skip to content

Commit ca03daa

Browse files
authored
Merge pull request #35078 from windsonsea/assignyhf
[zh-cn] resync /concepts/scheduling-eviction/assign-pod-node.md
2 parents 3f9a821 + 2bfdcc2 commit ca03daa

File tree

1 file changed

+41
-20
lines changed

1 file changed

+41
-20
lines changed

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

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ weight: 20
1818

1919
<!--
2020
You can constrain a {{< glossary_tooltip text="Pod" term_id="pod" >}} so that it can only run on particular set of
21-
{{< glossary_tooltip text="Node(s)" term_id="node" >}}.
22-
There are several ways to do this, and the recommended approaches all use
21+
{{< glossary_tooltip text="node(s)" term_id="node" >}}.
22+
There are several ways to do this and the recommended approaches all use
2323
[label selectors](/docs/concepts/overview/working-with-objects/labels/) to facilitate the selection.
2424
Generally such constraints are unnecessary, as the scheduler will automatically do a reasonable placement
25-
(e.g. spread your pods across nodes so as not place the pod on a node with insufficient free resources, etc.)
25+
(for example, spreading your Pods across nodes so as not place Pods on a node with insufficient free resources).
2626
However, there are some circumstances where you may want to control which node
27-
the Pod deploys to, for example, to ensure that a Pod ends up on a node with an SSD attached to it, or to co-locate pods from two different
27+
the Pod deploys to, for example, to ensure that a Pod ends up on a node with an SSD attached to it, or to co-locate Pods from two different
2828
services that communicate a lot into the same availability zone.
2929
-->
3030
你可以约束一个 {{< glossary_tooltip text="Pod" term_id="pod" >}}
@@ -172,6 +172,19 @@ define. Some of the benefits of affinity and anti-affinity include:
172172
* 你可以使用节点上(或其他拓扑域中)运行的其他 Pod 的标签来实施调度约束,
173173
而不是只能使用节点本身的标签。这个能力让你能够定义规则允许哪些 Pod 可以被放置在一起。
174174

175+
<!--
176+
The affinity feature consists of two types of affinity:
177+
178+
* *Node affinity* functions like the `nodeSelector` field but is more expressive and
179+
allows you to specify soft rules.
180+
* *Inter-pod affinity/anti-affinity* allows you to constrain Pods against labels
181+
on other Pods.
182+
-->
183+
亲和性功能由两种类型的亲和性组成:
184+
185+
* **节点亲和性**功能类似于 `nodeSelector` 字段,但它的表达能力更强,并且允许你指定软规则。
186+
* Pod 间亲和性/反亲和性允许你根据其他 Pod 的标签来约束 Pod。
187+
175188
<!--
176189
### Node affinity
177190
@@ -222,15 +235,16 @@ For example, consider the following Pod spec:
222235
<!--
223236
In this example, the following rules apply:
224237
225-
* The node *must* have a label with the key `kubernetes.io/os` and
226-
the value `linux`.
238+
* The node *must* have a label with the key `topology.kubernetes.io/zone` and
239+
the value of that label *must* be either `antarctica-east1` or `antarctica-west1`.
227240
* The node *preferably* has a label with the key `another-node-label-key` and
228241
the value `another-node-label-value`.
229242
-->
230243
在这一示例中,所应用的规则如下:
231244

232-
* 节点必须包含键名为 `kubernetes.io/os` 的标签,并且其取值为 `linux`
233-
* 节点 **最好** 具有键名为 `another-node-label-key` 且取值为
245+
* 节点**必须**包含一个键名为 `topology.kubernetes.io/zone` 的标签,
246+
并且该标签的取值**必须**`antarctica-east1``antarctica-west1`
247+
* 节点**最好**具有一个键名为 `another-node-label-key` 且取值为
234248
`another-node-label-value` 的标签。
235249

236250
<!--
@@ -269,7 +283,7 @@ satisfied.
269283
<!--
270284
If you specify multiple `matchExpressions` associated with a single `nodeSelectorTerms`,
271285
then the Pod can be scheduled onto a node only if all the `matchExpressions` are
272-
satisfied.
286+
satisfied.
273287
-->
274288
如果你指定了多个与同一 `nodeSelectorTerms` 关联的 `matchExpressions`
275289
则只有当所有 `matchExpressions` 都满足时 Pod 才可以被调度到节点上。
@@ -341,8 +355,8 @@ must have existing nodes with the `kubernetes.io/os=linux` label.
341355

342356
<!--
343357
When configuring multiple [scheduling profiles](/docs/reference/scheduling/config/#multiple-profiles), you can associate
344-
a profile with a Node affinity, which is useful if a profile only applies to a specific set of nodes.
345-
To do so, add an `addedAffinity` to the `args` field of the [`NodeAffinity` plugin](/docs/reference/scheduling/config/#scheduling-plugins)
358+
a profile with a node affinity, which is useful if a profile only applies to a specific set of nodes.
359+
To do so, add an `addedAffinity` to the `args` field of the [`NodeAffinity` plugin](/docs/reference/scheduling/config/#scheduling-plugins)
346360
in the [scheduler configuration](/docs/reference/scheduling/config/). For example:
347361
-->
348362
在配置多个[调度方案](/zh-cn/docs/reference/scheduling/config/#multiple-profiles)时,
@@ -410,7 +424,7 @@ Inter-pod affinity and anti-affinity allow you to constrain which nodes your
410424
Pods can be scheduled on based on the labels of **Pods** already running on that
411425
node, instead of the node labels.
412426
-->
413-
### pod 间亲和性与反亲和性 {#inter-pod-affinity-and-anti-affinity}
427+
### Pod 间亲和性与反亲和性 {#inter-pod-affinity-and-anti-affinity}
414428

415429
Pod 间亲和性与反亲和性使你可以基于已经在节点上运行的 **Pod** 的标签来约束
416430
Pod 可以调度到的节点,而不是基于节点上的标签。
@@ -552,9 +566,9 @@ same zone currently running Pods with the `Security=S2` Pod label.
552566

553567
<!--
554568
To get yourself more familiar with the examples of Pod affinity and anti-affinity,
555-
refer to the [design proposal](https://github.com/kubernetes/design-proposals-archive/blob/main/scheduling/podaffinity.md).
569+
refer to the [design proposal](https://git.k8s.io/design-proposals-archive/scheduling/podaffinity.md).
556570
-->
557-
查阅[设计文档](https://github.com/kubernetes/design-proposals-archive/blob/main/scheduling/podaffinity.md)
571+
查阅[设计文档](https://git.k8s.io/design-proposals-archive/scheduling/podaffinity.md)
558572
以进一步熟悉 Pod 亲和性与反亲和性的示例。
559573

560574
<!--
@@ -571,8 +585,7 @@ exceptions for performance and security reasons:
571585
有一些限制:
572586

573587
<!--
574-
* For Pod affinity and anti-affinity, an empty `topologyKey` field is not allowed in both
575-
`requiredDuringSchedulingIgnoredDuringExecution`
588+
* For Pod affinity and anti-affinity, an empty `topologyKey` field is not allowed in both `requiredDuringSchedulingIgnoredDuringExecution`
576589
and `preferredDuringSchedulingIgnoredDuringExecution`.
577590
* For `requiredDuringSchedulingIgnoredDuringExecution` Pod anti-affinity rules,
578591
the admission controller `LimitPodHardAntiAffinityTopology` limits
@@ -634,6 +647,14 @@ Pod 间亲和性与反亲和性在与更高级别的集合(例如 ReplicaSet
634647
Deployment 等)一起使用时,它们可能更加有用。
635648
这些规则使得你可以配置一组工作负载,使其位于相同定义拓扑(例如,节点)中。
636649

650+
<!--
651+
Take, for example, a three-node cluster running a web application with an
652+
in-memory cache like redis. You could use inter-pod affinity and anti-affinity
653+
to co-locate the web servers with the cache as much as possible.
654+
-->
655+
以一个三节点的集群为例,该集群运行一个带有 Redis 这种内存缓存的 Web 应用程序。
656+
你可以使用节点间的亲和性和反亲和性来尽可能地将 Web 服务器与缓存并置。
657+
637658
<!--
638659
In the following example Deployment for the redis cache, the replicas get the label `app=store`. The
639660
`podAntiAffinity` rule tells the scheduler to avoid placing multiple replicas
@@ -803,16 +824,16 @@ The above Pod will only run on the node `kube-01`.
803824

804825
<!--
805826
* Read more about [taints and tolerations](/docs/concepts/scheduling-eviction/taint-and-toleration/) .
806-
* Read the design docs for [node affinity](https://git.k8s.io/community/contributors/design-proposals/scheduling/nodeaffinity.md)
807-
and for [inter-pod affinity/anti-affinity](https://git.k8s.io/community/contributors/design-proposals/scheduling/podaffinity.md).
827+
* Read the design docs for [node affinity](https://git.k8s.io/design-proposals-archive/scheduling/nodeaffinity.md)
828+
and for [inter-pod affinity/anti-affinity](https://git.k8s.io/design-proposals-archive/scheduling/podaffinity.md).
808829
* Learn about how the [topology manager](/docs/tasks/administer-cluster/topology-manager/) takes part in node-level
809830
resource allocation decisions.
810831
* Learn how to use [nodeSelector](/docs/tasks/configure-pod-container/assign-pods-nodes/).
811832
* Learn how to use [affinity and anti-affinity](/docs/tasks/configure-pod-container/assign-pods-nodes-using-node-affinity/).
812833
-->
813834
* 进一步阅读[污点与容忍度](/zh-cn/docs/concepts/scheduling-eviction/taint-and-toleration/)文档。
814-
* 阅读[节点亲和性](https://git.k8s.io/community/contributors/design-proposals/scheduling/nodeaffinity.md)
815-
和[Pod 间亲和性与反亲和性](https://git.k8s.io/community/contributors/design-proposals/scheduling/podaffinity.md)
835+
* 阅读[节点亲和性](https://git.k8s.io/design-proposals-archive/scheduling/nodeaffinity.md)
836+
和[Pod 间亲和性与反亲和性](https://git.k8s.io/design-proposals-archive/scheduling/podaffinity.md)
816837
的设计文档。
817838
* 了解[拓扑管理器](/zh-cn/docs/tasks/administer-cluster/topology-manager/)如何参与节点层面资源分配决定。
818839
* 了解如何使用 [nodeSelector](/zh-cn/docs/tasks/configure-pod-container/assign-pods-nodes/)。

0 commit comments

Comments
 (0)