Skip to content

Commit c2121cc

Browse files
authored
Merge pull request #40622 from fenggw-fnst/sync-topology-spread-constraints
[zh-cn] Sync scheduling-eviction/topology-spread-constraints.md
2 parents 4b03d47 + 5eecfb0 commit c2121cc

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed

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

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ spec:
105105
topologyKey: <string>
106106
whenUnsatisfiable: <string>
107107
labelSelector: <object>
108-
matchLabelKeys: <list> # 可选;自从 v1.25 开始成为 Alpha
108+
matchLabelKeys: <list> # 可选;自从 v1.27 开始成为 Beta
109109
nodeAffinityPolicy: [Honor|Ignore] # 可选;自从 v1.26 开始成为 Beta
110110
nodeTaintsPolicy: [Honor|Ignore] # 可选;自从 v1.26 开始成为 Beta
111111
### 其他 Pod 字段置于此处
@@ -223,40 +223,54 @@ your cluster. Those fields are:
223223

224224
<!--
225225
- **matchLabelKeys** is a list of pod label keys to select the pods over which
226-
spreading will be calculated. The keys are used to lookup values from the pod labels, those key-value labels are ANDed with `labelSelector` to select the group of existing pods over which spreading will be calculated for the incoming pod. Keys that don't exist in the pod labels will be ignored. A null or empty list means only match against the `labelSelector`.
227-
228-
With `matchLabelKeys`, users don't need to update the `pod.spec` between different revisions. The controller/operator just needs to set different values to the same `label` key for different revisions. The scheduler will assume the values automatically based on `matchLabelKeys`. For example, if users use Deployment, they can use the label keyed with `pod-template-hash`, which is added automatically by the Deployment controller, to distinguish between different revisions in a single Deployment.
226+
spreading will be calculated. The keys are used to lookup values from the pod labels,
227+
those key-value labels are ANDed with `labelSelector` to select the group of existing
228+
pods over which spreading will be calculated for the incoming pod. The same key is
229+
forbidden to exist in both `matchLabelKeys` and `labelSelector`. `matchLabelKeys` cannot
230+
be set when `labelSelector` isn't set. Keys that don't exist in the pod labels will be
231+
ignored. A null or empty list means only match against the `labelSelector`.
232+
233+
With `matchLabelKeys`, you don't need to update the `pod.spec` between different revisions.
234+
The controller/operator just needs to set different values to the same label key for different
235+
revisions. The scheduler will assume the values automatically based on `matchLabelKeys`. For
236+
example, if you are configuring a Deployment, you can use the label keyed with
237+
[pod-template-hash](/docs/concepts/workloads/controllers/deployment/#pod-template-hash-label), which
238+
is added automatically by the Deployment controller, to distinguish between different revisions
239+
in a single Deployment.
229240
-->
230241
- **matchLabelKeys** 是一个 Pod 标签键的列表,用于选择需要计算分布方式的 Pod 集合。
231242
这些键用于从 Pod 标签中查找值,这些键值标签与 `labelSelector` 进行逻辑与运算,以选择一组已有的 Pod,
232-
通过这些 Pod 计算新来 Pod 的分布方式。Pod 标签中不存在的键将被忽略。
243+
通过这些 Pod 计算新来 Pod 的分布方式。`matchLabelKeys``labelSelector` 中禁止存在相同的键。
244+
未设置 `labelSelector` 时无法设置 `matchLabelKeys`。Pod 标签中不存在的键将被忽略。
233245
null 或空列表意味着仅与 `labelSelector` 匹配。
234246

235-
借助 `matchLabelKeys`,用户无需在变更 Pod 修订版本时更新 `pod.spec`
236-
控制器或 Operator 只需要将不同修订版的 `label` 键设为不同的值。
237-
调度器将根据 `matchLabelKeys` 自动确定取值。例如,如果用户使用 Deployment,
238-
则他们可以使用由 Deployment 控制器自动添加的、以 `pod-template-hash` 为键的标签来区分单个
239-
Deployment 的不同修订版。
247+
借助 `matchLabelKeys`,你无需在变更 Pod 修订版本时更新 `pod.spec`
248+
控制器或 Operator 只需要将不同修订版的标签键设为不同的值。
249+
调度器将根据 `matchLabelKeys` 自动确定取值。例如,如果你正在配置一个 Deployment,
250+
则你可以使用由 Deployment 控制器自动添加的、以
251+
[pod-template-hash](/zh-cn/docs/concepts/workloads/controllers/deployment/#pod-template-hash-label)
252+
为键的标签来区分同一个 Deployment 的不同修订版。
240253

241254
```yaml
242255
topologySpreadConstraints:
243256
- maxSkew: 1
244257
topologyKey: kubernetes.io/hostname
245258
whenUnsatisfiable: DoNotSchedule
259+
labelSelector:
260+
matchLabels:
261+
app: foo
246262
matchLabelKeys:
247-
- app
248263
- pod-template-hash
249264
```
250265
251266
{{< note >}}
252267
<!--
253-
The `matchLabelKeys` field is an alpha field added in 1.25. You have to enable the
254-
`MatchLabelKeysInPodTopologySpread` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
255-
in order to use it.
268+
The `matchLabelKeys` field is a beta-level field and enabled by default in 1.27. You can disable it by disabling the
269+
`MatchLabelKeysInPodTopologySpread` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/).
256270
-->
257-
`matchLabelKeys` 字段是 1.25 中新增的一个 Alpha 字段
258-
你必须启用 `MatchLabelKeysInPodTopologySpread`
259-
[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)才能使用此字段
271+
`matchLabelKeys` 字段是 1.27 中默认启用的一个 Beta 级别字段
272+
你可以通过禁用 `MatchLabelKeysInPodTopologySpread`
273+
[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)来禁用此字段
260274
{{< /note >}}
261275

262276
<!--

0 commit comments

Comments
 (0)