@@ -28,19 +28,19 @@ nodes.
28
28
{{< version-check >}}
29
29
30
30
<!--
31
- * You are the owner of an application running on a Kubernetes cluster that requires
31
+ - You are the owner of an application running on a Kubernetes cluster that requires
32
32
high availability.
33
- * You should know how to deploy [Replicated Stateless Applications](/docs/tasks/run-application/run-stateless-application-deployment/)
33
+ - You should know how to deploy [Replicated Stateless Applications](/docs/tasks/run-application/run-stateless-application-deployment/)
34
34
and/or [Replicated Stateful Applications](/docs/tasks/run-application/run-replicated-stateful-application/).
35
- * You should have read about [Pod Disruptions](/docs/concepts/workloads/pods/disruptions/).
36
- * You should confirm with your cluster owner or service provider that they respect
35
+ - You should have read about [Pod Disruptions](/docs/concepts/workloads/pods/disruptions/).
36
+ - You should confirm with your cluster owner or service provider that they respect
37
37
Pod Disruption Budgets.
38
38
-->
39
- * 你是 Kubernetes 集群中某应用的所有者,该应用有高可用要求。
40
- * 你应了解如何部署[ 无状态应用] ( /zh-cn/docs/tasks/run-application/run-stateless-application-deployment/ )
39
+ - 你是 Kubernetes 集群中某应用的所有者,该应用有高可用要求。
40
+ - 你应了解如何部署[ 无状态应用] ( /zh-cn/docs/tasks/run-application/run-stateless-application-deployment/ )
41
41
和/或[ 有状态应用] ( /zh-cn/docs/tasks/run-application/run-replicated-stateful-application/ ) 。
42
- * 你应当已经阅读过关于 [ Pod 干扰] ( /zh-cn/docs/concepts/workloads/pods/disruptions/ ) 的文档。
43
- * 用户应当与集群所有者或服务提供者确认其遵从 Pod 干扰预算(Pod Disruption Budgets)的规则。
42
+ - 你应当已经阅读过关于 [ Pod 干扰] ( /zh-cn/docs/concepts/workloads/pods/disruptions/ ) 的文档。
43
+ - 用户应当与集群所有者或服务提供者确认其遵从 Pod 干扰预算(Pod Disruption Budgets)的规则。
44
44
45
45
<!-- steps -->
46
46
@@ -52,11 +52,11 @@ nodes.
52
52
1. Create a PDB definition as a YAML file.
53
53
1. Create the PDB object from the YAML file.
54
54
-->
55
- ## 用 PodDisruptionBudget 来保护应用
55
+ ## 用 PodDisruptionBudget 来保护应用 {#protecting-app-with-pdb}
56
56
57
57
1 . 确定想要使用 PodDisruptionBudget (PDB) 来保护的应用。
58
58
1 . 考虑应用对干扰的反应。
59
- 1 . 以 YAML 文件形式定义 PDB 。
59
+ 1 . 以 YAML 文件形式定义 PDB。
60
60
1 . 通过 YAML 文件创建 PDB 对象。
61
61
62
62
<!-- discussion -->
67
67
The most common use case when you want to protect an application
68
68
specified by one of the built-in Kubernetes controllers:
69
69
-->
70
- ## 确定要保护的应用
70
+ ## 确定要保护的应用 {#identify-app-to-protect}
71
71
72
72
用户想要保护通过内置的 Kubernetes 控制器指定的应用,这是最常见的使用场景:
73
73
@@ -150,60 +150,62 @@ due to a voluntary disruption.
150
150
151
151
Values for `minAvailable` or `maxUnavailable` can be expressed as integers or as a percentage.
152
152
-->
153
- ### 指定百分比时的舍入逻辑
153
+ ### 指定百分比时的舍入逻辑 {#rounding-logic-when-specifying-percentages}
154
154
155
155
` minAvailable ` 或 ` maxUnavailable ` 的值可以表示为整数或百分比。
156
156
157
157
<!--
158
158
- When you specify an integer, it represents a number of Pods. For instance, if you set `minAvailable` to 10, then 10
159
159
Pods must always be available, even during a disruption.
160
160
- When you specify a percentage by setting the value to a string representation of a percentage (eg. `"50%"`), it represents a percentage of
161
- total Pods. For instance, if you set `maxUnavailable ` to `"50%"`, then only 50% of the Pods can be unavailable during a
161
+ total Pods. For instance, if you set `minAvailable ` to `"50%"`, then at least 50% of the Pods remain available during a
162
162
disruption.
163
163
-->
164
- - 指定整数值时,它表示 Pod 个数。例如,如果将 minAvailable 设置为 10,
165
- 那么即使在干扰期间,也必须始终有 10 个Pod可用 。
166
- - 通过将值设置为百分比的字符串表示形式(例如 “ 50%” )来指定百分比时,它表示占总 Pod 数的百分比。
167
- 例如,如果将 "maxUnavailable" 设置为 “ 50%”,则干扰期间只允许 50% 的 Pod 不可用 。
164
+ - 指定整数值时,它表示 Pod 个数。例如,如果将 ` minAvailable ` 设置为 10,
165
+ 那么即使在干扰期间,也必须始终有 10 个 Pod 可用 。
166
+ - 通过将值设置为百分比的字符串表示形式(例如 ` " 50%" ` )来指定百分比时,它表示占总 Pod 数的百分比。
167
+ 例如,如果将 ` minAvailable ` 设置为 ` " 50%" ` ,则干扰期间至少 50% 的 Pod 保持可用 。
168
168
169
169
<!--
170
170
When you specify the value as a percentage, it may not map to an exact number of Pods. For example, if you have 7 Pods and
171
171
you set `minAvailable` to `"50%"`, it's not immediately obvious whether that means 3 Pods or 4 Pods must be available.
172
- Kubernetes rounds up to the nearest integer, so in this case, 4 Pods must be available. You can examine the
172
+ Kubernetes rounds up to the nearest integer, so in this case, 4 Pods must be available. When you specify the value
173
+ `maxUnavailable` as a percentage, Kubernetes rounds up the number of Pods that may be disrupted. Thereby a disruption
174
+ can exceed your defined `maxUnavailable` percentage. You can examine the
173
175
[code](https://github.com/kubernetes/kubernetes/blob/23be9587a0f8677eb8091464098881df939c44a9/pkg/controller/disruption/disruption.go#L539)
174
176
that controls this behavior.
175
177
-->
176
178
如果将值指定为百分比,则可能无法映射到确切数量的 Pod。例如,如果你有 7 个 Pod,
177
- 并且你将 ` minAvailable ` 设置为 ` "50%" ` ,具体是 3 个 Pod 或 4 个 Pod 必须可用
178
- 并非显而易见。
179
+ 并且你将 ` minAvailable ` 设置为 ` "50%" ` ,具体是 3 个 Pod 或 4 个 Pod 必须可用并非显而易见。
179
180
Kubernetes 采用向上取整到最接近的整数的办法,因此在这种情况下,必须有 4 个 Pod。
180
- 你可以检查控制此行为的
181
- [ 代码] ( https://github.com/kubernetes/kubernetes/blob/23be9587a0f8677eb8091464098881df939c44a9/pkg/controller/disruption/disruption.go#L539 ) 。
181
+ 当你将 ` maxUnavailable ` 值指定为一个百分比时,Kubernetes 将可以干扰的 Pod 个数向上取整。
182
+ 因此干扰可以超过你定义的 ` maxUnavailable ` 百分比。
183
+ 你可以检查控制此行为的[ 代码] ( https://github.com/kubernetes/kubernetes/blob/23be9587a0f8677eb8091464098881df939c44a9/pkg/controller/disruption/disruption.go#L539 ) 。
182
184
183
185
<!--
184
186
## Specifying a PodDisruptionBudget
185
187
186
188
A `PodDisruptionBudget` has three fields:
187
189
-->
188
- ## 指定 PodDisruptionBudget
190
+ ## 指定 PodDisruptionBudget {#specifying-a-poddisruptionbudget}
189
191
190
192
一个 ` PodDisruptionBudget ` 有 3 个字段:
191
193
192
194
<!--
193
- * A label selector `.spec.selector` to specify the set of
194
- pods to which it applies. This field is required.
195
- * `.spec.minAvailable` which is a description of the number of pods from that
196
- set that must still be available after the eviction, even in the absence
197
- of the evicted pod. `minAvailable` can be either an absolute number or a percentage.
198
- * `.spec.maxUnavailable` (available in Kubernetes 1.7 and higher) which is a description
199
- of the number of pods from that set that can be unavailable after the eviction.
200
- It can be either an absolute number or a percentage.
195
+ - A label selector `.spec.selector` to specify the set of
196
+ pods to which it applies. This field is required.
197
+ - `.spec.minAvailable` which is a description of the number of pods from that
198
+ set that must still be available after the eviction, even in the absence
199
+ of the evicted pod. `minAvailable` can be either an absolute number or a percentage.
200
+ - `.spec.maxUnavailable` (available in Kubernetes 1.7 and higher) which is a description
201
+ of the number of pods from that set that can be unavailable after the eviction.
202
+ It can be either an absolute number or a percentage.
201
203
-->
202
- * 标签选择算符 ` .spec.selector ` 用于指定其所作用的 Pod 集合,该字段为必需字段。
203
- * ` .spec.minAvailable ` 表示驱逐后仍须保证可用的 Pod 数量。即使因此影响到 Pod 驱逐
204
+ - 标签选择算符 ` .spec.selector ` 用于指定其所作用的 Pod 集合,该字段为必需字段。
205
+ - ` .spec.minAvailable ` 表示驱逐后仍须保证可用的 Pod 数量。即使因此影响到 Pod 驱逐
204
206
(即该条件在和 Pod 驱逐发生冲突时优先保证)。
205
207
` minAvailable ` 值可以是绝对值,也可以是百分比。
206
- * ` .spec.maxUnavailable ` (Kubernetes 1.7 及更高的版本中可用)表示驱逐后允许不可用的
208
+ - ` .spec.maxUnavailable ` (Kubernetes 1.7 及更高的版本中可用)表示驱逐后允许不可用的
207
209
Pod 的最大数量。其值可以是绝对值或是百分比。
208
210
209
211
{{< note >}}
@@ -249,10 +251,14 @@ unhealthy replicas among the total number of desired replicas.
249
251
示例 3:设置 ` maxUnavailable ` 值为 5 的情况下,驱逐时需保证所需副本中最多 5 个处于不可用状态。
250
252
251
253
<!--
252
- Example 4: With a `maxUnavailable` of 30%, evictions are allowed as long as no more than 30%
253
- of the desired replicas are unhealthy.
254
+ Example 4: With a `maxUnavailable` of 30%, evictions are allowed as long as the number of
255
+ unhealthy replicas does not exceed 30% of the total number of desired replica rounded up to
256
+ the nearest integer. If the total number of desired replicas is just one, that single replica
257
+ is still allowed for disruption, leading to an effective unavailability of 100%.
254
258
-->
255
- 示例 4:设置 ` maxUnavailable ` 值为 30% 的情况下,驱逐时需保证所需副本中最多 30% 处于不可用状态。
259
+ 示例 4:设置 ` maxUnavailable ` 值为 30% 的情况下,只要不健康的副本数量不超过所需副本总数的 30%
260
+ (取整到最接近的整数),就允许驱逐。如果所需副本的总数仅为一个,则仍允许该单个副本中断,
261
+ 从而导致不可用性实际达到 100%。
256
262
257
263
<!--
258
264
In typical usage, a single budget would be used for a collection of pods managed by
@@ -270,9 +276,9 @@ specified in the budget, thus bringing the number of available pods from the
270
276
collection below the specified size. The budget can only protect against
271
277
voluntary evictions, not all causes of unavailability.
272
278
-->
273
- 干扰预算并不能真正保证指定数量/百分比的 Pod 一直处于运行状态。例如: 当 Pod 集合的
274
- 规模处于预算指定的最小值时 ,承载集合中某个 Pod 的节点发生了故障,这样就导致集合中可用 Pod 的
275
- 数量低于预算指定值 。预算只能够针对自发的驱逐提供保护,而不能针对所有 Pod 不可用的诱因。
279
+ 干扰预算并不能真正保证指定数量/百分比的 Pod 一直处于运行状态。例如:当 Pod
280
+ 集合的规模处于预算指定的最小值时 ,承载集合中某个 Pod 的节点发生了故障,这样就导致集合中可用
281
+ Pod 的数量低于预算指定值 。预算只能够针对自发的驱逐提供保护,而不能针对所有 Pod 不可用的诱因。
276
282
{{< /note >}}
277
283
278
284
<!--
@@ -292,12 +298,12 @@ semantics of `PodDisruptionBudget`.
292
298
You can find examples of pod disruption budgets defined below. They match pods with the label
293
299
`app: zookeeper`.
294
300
-->
295
- 用户可以在下面看到 pod 干扰预算定义的示例,它们与带有 ` app: zookeeper ` 标签的 pod 相匹配:
301
+ 用户可以在下面看到 Pod 干扰预算定义的示例,它们与带有 ` app: zookeeper ` 标签的 Pod 相匹配:
296
302
297
303
<!--
298
304
Example PDB Using minAvailable:
299
305
-->
300
- 使用 minAvailable 的PDB 示例:
306
+ 使用 minAvailable 的 PDB 示例:
301
307
302
308
{{< codenew file="policy/zookeeper-pod-disruption-budget-minavailable.yaml" >}}
303
309
@@ -315,34 +321,27 @@ automatically responds to changes in the number of replicas of the corresponding
315
321
-->
316
322
例如,如果上述 ` zk-pdb ` 选择的是一个规格为 3 的 StatefulSet 对应的 Pod,
317
323
那么上面两种规范的含义完全相同。
318
- 推荐使用 ` maxUnavailable ` ,因为它自动响应控制器副本数量的变化。
324
+ 推荐使用 ` maxUnavailable ` ,因为它自动响应控制器副本数量的变化。
319
325
320
326
<!--
321
327
## Create the PDB object
322
328
323
329
You can create or update the PDB object using kubectl.
324
- ```shell
325
- kubectl apply -f mypdb.yaml
326
- ```
327
330
-->
328
- ## 创建 PDB 对象
331
+ ## 创建 PDB 对象 {#create-pdb-object}
329
332
330
333
你可以使用 kubectl 创建或更新 PDB 对象。
334
+
331
335
``` shell
332
336
kubectl apply -f mypdb.yaml
333
337
```
334
338
335
- <!--
336
- You cannot update PDB objects. They must be deleted and re-created.
337
- -->
338
- PDB 对象无法更新,必须删除后重新创建。
339
-
340
339
<!--
341
340
## Check the status of the PDB
342
341
343
342
Use kubectl to check that your PDB is created.
344
343
-->
345
- ## 检查 PDB 的状态
344
+ ## 检查 PDB 的状态 {#check-status-of-pdb}
346
345
347
346
使用 kubectl 来确认 PDB 被创建。
348
347
@@ -531,5 +530,5 @@ so most users will want to avoid overlapping selectors. One reasonable use of ov
531
530
PDBs is when pods are being transitioned from one PDB to another.
532
531
-->
533
532
你可以令选择算符选择一个内置控制器所控制 Pod 的子集或父集。
534
- 驱逐 API 将不允许驱逐被多个 PDB 覆盖的任何 Pod,因此大多数用户都希望避免重叠的选择算符。重叠 PDB 的一种合理用途是当 Pod 从一个 PDB 过渡到另一个 PDB 时再使用。
535
-
533
+ 驱逐 API 将不允许驱逐被多个 PDB 覆盖的任何 Pod,因此大多数用户都希望避免重叠的选择算符。
534
+ 重叠 PDB 的一种合理用途是当 Pod 从一个 PDB 过渡到另一个 PDB 时再使用。
0 commit comments