Skip to content

Commit 803abfe

Browse files
authored
Merge pull request #39441 from tengqm/zh-resync-qos
[zh] Resync QoS Pod page
2 parents da84dd8 + f4082ee commit 803abfe

File tree

1 file changed

+109
-73
lines changed

1 file changed

+109
-73
lines changed

content/zh-cn/docs/tasks/configure-pod-container/quality-service-pod.md

Lines changed: 109 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,46 @@ weight: 30
1414

1515
<!--
1616
This page shows how to configure Pods so that they will be assigned particular
17-
Quality of Service (QoS) classes. Kubernetes uses QoS classes to make decisions about
18-
scheduling and evicting Pods.
17+
{{< glossary_tooltip text="Quality of Service (QoS) classes" term_id="qos-class" >}}.
18+
Kubernetes uses QoS classes to make decisions about evicting Pods when Node resources are exceeded.
1919
-->
20-
本页介绍怎样配置 Pod 让其获得特定的服务质量(QoS)类。Kubernetes 使用 QoS 类来决定 Pod 的调度和驱逐策略。
20+
本页介绍怎样配置 Pod 以让其归属于特定的
21+
{{< glossary_tooltip text="服务质量类(Quality of Service class,QoS class)" term_id="qos-class" >}}.
22+
Kubernetes 在 Node 资源不足时使用 QoS 类来就驱逐 Pod 作出决定。
2123

22-
## {{% heading "prerequisites" %}}
24+
<!--
25+
When Kubernetes creates a Pod it assigns one of these QoS classes to the Pod:
2326
24-
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
27+
* [Guaranteed](/docs/concepts/workloads/pods/pod-qos/#guaranteed)
28+
* [Burstable](/docs/concepts/workloads/pods/pod-qos/#burstable)
29+
* [BestEffort](/docs/concepts/workloads/pods/pod-qos/#besteffort)
30+
-->
31+
Kubernetes 创建 Pod 时,会将如下 QoS 类之一设置到 Pod 上:
2532

26-
<!-- steps -->
33+
* [Guaranteed](/zh-cn/docs/concepts/workloads/pods/pod-qos/#guaranteed)
34+
* [Burstable](/zh-cn/docs/concepts/workloads/pods/pod-qos/#burstable)
35+
* [BestEffort](/zh-cn/docs/concepts/workloads/pods/pod-qos/#besteffort)
2736

28-
<!--
29-
## QoS classes
37+
## {{% heading "prerequisites" %}}
3038

31-
When Kubernetes creates a Pod it assigns one of these QoS classes to the Pod:
32-
-->
33-
## QoS 类 {#qos-classes}
39+
{{< include "task-tutorial-prereqs.md" >}}
3440

35-
Kubernetes 创建 Pod 时就给它指定了下列一种 QoS 类:
41+
<!--
42+
You also need to be able to create and delete namespaces.
43+
-->
44+
你还需要能够创建和删除名字空间。
3645

37-
* Guaranteed
38-
* Burstable
39-
* BestEffort
46+
<!-- steps -->
4047

4148
<!--
4249
## Create a namespace
4350
4451
Create a namespace so that the resources you create in this exercise are
4552
isolated from the rest of your cluster.
4653
-->
47-
## 创建命名空间 {#create-a-namespace}
54+
## 创建名字空间 {#create-a-namespace}
4855

49-
创建一个命名空间,以便将本练习所创建的资源与集群的其余资源相隔离。
56+
创建一个名字空间,以便将本练习所创建的资源与集群的其余资源相隔离。
5057

5158
```shell
5259
kubectl create namespace qos-example
@@ -62,10 +69,6 @@ For a Pod to be given a QoS class of Guaranteed:
6269
* Every Container in the Pod must have a CPU limit and a CPU request.
6370
* For every Container in the Pod, the CPU limit must equal the CPU request.
6471
65-
These restrictions apply to init containers and app containers equally.
66-
67-
Here is the configuration file for a Pod that has one Container. The Container has a memory limit and a
68-
memory request, both equal to 200 MiB. The Container has a CPU limit and a CPU request, both equal to 700 milliCPU:
6972
-->
7073
## 创建一个 QoS 类为 Guaranteed 的 Pod {#create-a-pod-that-gets-assigned-a-qos-class-of-guaranteed}
7174

@@ -76,11 +79,21 @@ memory request, both equal to 200 MiB. The Container has a CPU limit and a CPU r
7679
* Pod 中的每个容器都必须指定 CPU 限制和 CPU 请求。
7780
* 对于 Pod 中的每个容器,CPU 限制必须等于 CPU 请求。
7881

82+
<!--
83+
These restrictions apply to init containers and app containers equally.
84+
[Ephemeral containers](/docs/concepts/workloads/pods/ephemeral-containers/)
85+
cannot define resources so these restrictions do not apply.
86+
87+
Here is a manifest for a Pod that has one Container. The Container has a memory limit and a
88+
memory request, both equal to 200 MiB. The Container has a CPU limit and a CPU request, both equal to 700 milliCPU:
89+
-->
90+
7991
这些限制同样适用于初始化容器和应用程序容器。
92+
[临时容器(Ephemeral Container)](/zh-cn/docs/concepts/workloads/pods/ephemeral-containers/)
93+
无法定义资源,因此不受这些约束限制。
8094

81-
下面是包含一个容器的 Pod 配置文件。
82-
该容器设置了内存请求和内存限制,值都是 200 MiB。
83-
该容器设置了 CPU 请求和 CPU 限制,值都是 700 milliCPU:
95+
下面是包含一个 Container 的 Pod 清单。该 Container 设置了内存请求和内存限制,值都是 200 MiB。
96+
该 Container 设置了 CPU 请求和 CPU 限制,值都是 700 milliCPU:
8497

8598
{{< codenew file="pods/qos/qos-pod.yaml" >}}
8699

@@ -133,10 +146,16 @@ automatically assigns a memory request that matches the limit. Similarly, if a C
133146
CPU limit, but does not specify a CPU request, Kubernetes automatically assigns a CPU request that matches
134147
the limit.
135148
-->
136-
如果容器指定了自己的内存限制,但没有指定内存请求,Kubernetes 会自动为它指定与内存限制匹配的内存请求。
137-
同样,如果容器指定了自己的 CPU 限制,但没有指定 CPU 请求,Kubernetes 会自动为它指定与 CPU 限制匹配的 CPU 请求。
149+
如果某 Container 指定了自己的内存限制,但没有指定内存请求,Kubernetes
150+
会自动为它指定与内存限制相等的内存请求。同样,如果容器指定了自己的 CPU 限制,
151+
但没有指定 CPU 请求,Kubernetes 会自动为它指定与 CPU 限制相等的 CPU 请求。
138152
{{< /note >}}
139153
154+
<!--
155+
#### Clean up {#clean-up-guaranteed}
156+
-->
157+
#### 清理 {#clean-up-guaranteed}
158+
140159
<!--
141160
Delete your Pod:
142161
-->
@@ -149,23 +168,23 @@ kubectl delete pod qos-demo --namespace=qos-example
149168
<!--
150169
## Create a Pod that gets assigned a QoS class of Burstable
151170
152-
A Pod is given a QoS class of Burstable if:
171+
A Pod is given a QoS class of `Burstable` if:
153172
154-
* The Pod does not meet the criteria for QoS class Guaranteed.
173+
* The Pod does not meet the criteria for QoS class `Guaranteed`.
155174
* At least one Container in the Pod has a memory or CPU request or limit.
156175
157-
Here is the configuration file for a Pod that has one Container. The Container has a memory limit of 200 MiB
176+
Here is a manifest for a Pod that has one Container. The Container has a memory limit of 200 MiB
158177
and a memory request of 100 MiB.
159178
-->
160179
## 创建一个 QoS 类为 Burstable 的 Pod {#create-a-pod-that-gets-assigned-a-qos-class-of-burstable}
161180

162-
如果满足下面条件,将会指定 Pod 的 QoS 类为 Burstable:
181+
如果满足下面条件,Kubernetes 将会指定 Pod 的 QoS 类为 `Burstable`
163182

164-
* Pod 不符合 Guaranteed QoS 类的标准。
165-
* Pod 中至少一个容器具有内存或 CPU 的请求或限制。
183+
* Pod 不符合 `Guaranteed` QoS 类的标准。
184+
* Pod 中至少一个 Container 具有内存或 CPU 的请求或限制。
166185

167-
下面是包含一个容器的 Pod 配置文件。
168-
该容器设置了内存限制 200 MiB 和内存请求 100 MiB。
186+
下面是包含一个 Container 的 Pod 清单。该 Container 设置的内存限制为 200 MiB,
187+
内存请求为 100 MiB。
169188

170189
{{< codenew file="pods/qos/qos-pod-2.yaml" >}}
171190

@@ -188,9 +207,9 @@ kubectl get pod qos-demo-2 --namespace=qos-example --output=yaml
188207
```
189208

190209
<!--
191-
The output shows that Kubernetes gave the Pod a QoS class of Burstable.
210+
The output shows that Kubernetes gave the Pod a QoS class of `Burstable`:
192211
-->
193-
结果表明 Kubernetes 为 Pod 配置的 QoS 类为 Burstable。
212+
结果表明 Kubernetes 为 Pod 配置的 QoS 类为 `Burstable`
194213

195214
```yaml
196215
spec:
@@ -208,6 +227,11 @@ status:
208227
qosClass: Burstable
209228
```
210229
230+
<!--
231+
#### Clean up {#clean-up-burstable}
232+
-->
233+
#### 清理 {#clean-up-burstable}
234+
211235
<!--
212236
Delete your Pod:
213237
-->
@@ -220,18 +244,17 @@ kubectl delete pod qos-demo-2 --namespace=qos-example
220244
<!--
221245
## Create a Pod that gets assigned a QoS class of BestEffort
222246
223-
For a Pod to be given a QoS class of BestEffort, the Containers in the Pod must not
247+
For a Pod to be given a QoS class of `BestEffort`, the Containers in the Pod must not
224248
have any memory or CPU limits or requests.
225249
226250
Here is the configuration file for a Pod that has one Container. The Container has no memory or CPU
227251
limits or requests:
228252
-->
229253
## 创建一个 QoS 类为 BestEffort 的 Pod {#create-a-pod-that-gets-assigned-a-qos-class-of-besteffort}
230254

231-
对于 QoS 类为 BestEffort 的 Pod,Pod 中的容器必须没有设置内存和 CPU 限制或请求。
255+
对于 QoS 类为 `BestEffort` 的 Pod,Pod 中的 Container 必须没有设置内存和 CPU 限制或请求。
232256

233-
下面是包含一个容器的 Pod 配置文件。
234-
该容器没有设置内存和 CPU 限制或请求。
257+
下面是包含一个 Container 的 Pod 清单。该 Container 没有设置内存和 CPU 限制或请求。
235258

236259
{{< codenew file="pods/qos/qos-pod-3.yaml" >}}
237260

@@ -254,9 +277,9 @@ kubectl get pod qos-demo-3 --namespace=qos-example --output=yaml
254277
```
255278

256279
<!--
257-
The output shows that Kubernetes gave the Pod a QoS class of BestEffort.
280+
The output shows that Kubernetes gave the Pod a QoS class of `BestEffort`:
258281
-->
259-
结果表明 Kubernetes 为 Pod 配置的 QoS 类为 BestEffort。
282+
结果表明 Kubernetes 为 Pod 配置的 QoS 类为 `BestEffort`
260283

261284
```yaml
262285
spec:
@@ -268,6 +291,11 @@ status:
268291
qosClass: BestEffort
269292
```
270293
294+
<!--
295+
#### Clean up {#clean-up-besteffort}
296+
-->
297+
#### 清理 {#clean-up-besteffort}
298+
271299
<!--
272300
Delete your Pod:
273301
-->
@@ -285,20 +313,19 @@ request of 200 MiB. The other Container does not specify any requests or limits.
285313
-->
286314
## 创建包含两个容器的 Pod {#create-a-pod-that-has-two-containers}
287315

288-
下面是包含两个容器的 Pod 配置文件。
289-
一个容器指定了内存请求 200 MiB。
290-
另外一个容器没有指定任何请求和限制。
316+
下面是包含两个 Container 的 Pod 配置文件。一个 Container 指定内存请求为 200 MiB。
317+
另外一个 Container 没有指定任何请求或限制。
291318

292319
{{< codenew file="pods/qos/qos-pod-4.yaml" >}}
293320

294321
<!--
295-
Notice that this Pod meets the criteria for QoS class Burstable. That is, it does not meet the
322+
Notice that this Pod meets the criteria for QoS class `Burstable`. That is, it does not meet the
296323
criteria for QoS class Guaranteed, and one of its Containers has a memory request.
297324
298325
Create the Pod:
299326
-->
300-
注意此 Pod 满足 Burstable QoS 类的标准。
301-
也就是说它不满足 Guaranteed QoS 类标准,因为它的一个容器设有内存请求
327+
注意此 Pod 满足 `Burstable` QoS 类的标准。也就是说它不满足 Guaranteed QoS 类标准,
328+
因为它的 Container 之一设有内存请求
302329

303330
创建 Pod:
304331

@@ -316,9 +343,9 @@ kubectl get pod qos-demo-4 --namespace=qos-example --output=yaml
316343
```
317344

318345
<!--
319-
The output shows that Kubernetes gave the Pod a QoS class of Burstable:
346+
The output shows that Kubernetes gave the Pod a QoS class of `Burstable`:
320347
-->
321-
结果表明 Kubernetes 为 Pod 配置的 QoS 类为 Burstable:
348+
结果表明 Kubernetes 为 Pod 配置的 QoS 类为 `Burstable`
322349

323350
```yaml
324351
spec:
@@ -336,6 +363,31 @@ status:
336363
qosClass: Burstable
337364
```
338365
366+
<!--
367+
## Retrieve the QoS class for a Pod
368+
369+
Rather than see all the fields, you can view just the field you need:
370+
-->
371+
## 检视 Pod 的 QoS 类 {#retrieve-the-qos-class-for-a-pod}
372+
373+
<!--
374+
Rather than see all the fields, you can view just the field you need:
375+
-->
376+
你也可以只查看你所需要的字段,而不是查看所有字段:
377+
378+
```bash
379+
kubectl --namespace=qos-example get pod qos-demo-4 -o jsonpath='{ .status.qosClass}{"\n"}'
380+
```
381+
382+
```none
383+
Burstable
384+
```
385+
386+
<!--
387+
## Clean up
388+
-->
389+
## 清理 {#clean-up}
390+
339391
<!--
340392
Delete your Pod:
341393
-->
@@ -352,7 +404,7 @@ Delete your namespace:
352404
-->
353405
## 环境清理 {#clean-up}
354406

355-
删除命名空间
407+
删除名字空间
356408

357409
```shell
358410
kubectl delete namespace qos-example
@@ -370,44 +422,28 @@ kubectl delete namespace qos-example
370422
### 应用开发者参考
371423

372424
* [为 Pod 和容器分配内存资源](/zh-cn/docs/tasks/configure-pod-container/assign-memory-resource/)
373-
374425
* [为 Pod 和容器分配 CPU 资源](/zh-cn/docs/tasks/configure-pod-container/assign-cpu-resource/)
375426

376427
<!--
377428
### For cluster administrators
378429
379430
* [Configure Default Memory Requests and Limits for a Namespace](/docs/tasks/administer-cluster/manage-resources/memory-default-namespace/)
380-
381431
* [Configure Default CPU Requests and Limits for a Namespace](/docs/tasks/administer-cluster/manage-resources/cpu-default-namespace/)
382-
383432
* [Configure Minimum and Maximum Memory Constraints for a Namespace](/docs/tasks/administer-cluster/manage-resources/memory-constraint-namespace/)
384-
385433
* [Configure Minimum and Maximum CPU Constraints for a Namespace](/docs/tasks/administer-cluster/manage-resources/cpu-constraint-namespace/)
386-
387434
* [Configure Memory and CPU Quotas for a Namespace](/docs/tasks/administer-cluster/manage-resources/quota-memory-cpu-namespace/)
388-
389435
* [Configure a Pod Quota for a Namespace](/docs/tasks/administer-cluster/manage-resources/quota-pod-namespace/)
390-
391436
* [Configure Quotas for API Objects](/docs/tasks/administer-cluster/quota-api-object/)
392-
393437
* [Control Topology Management policies on a node](/docs/tasks/administer-cluster/topology-manager/)
394438
-->
395-
396439
### 集群管理员参考
397440

398-
* [为命名空间配置默认的内存请求和限制](/zh-cn/docs/tasks/administer-cluster/manage-resources/memory-default-namespace/)
399-
400-
* [为命名空间配置默认的 CPU 请求和限制](/zh-cn/docs/tasks/administer-cluster/manage-resources/cpu-default-namespace/)
401-
402-
* [为命名空间配置最小和最大内存限制](/zh-cn/docs/tasks/administer-cluster/manage-resources/memory-constraint-namespace/)
403-
404-
* [为命名空间配置最小和最大 CPU 限制](/zh-cn/docs/tasks/administer-cluster/manage-resources/cpu-constraint-namespace/)
405-
406-
* [为命名空间配置内存和 CPU 配额](/zh-cn/docs/tasks/administer-cluster/manage-resources/quota-memory-cpu-namespace/)
407-
408-
* [为命名空间配置 Pod 配额](/zh-cn/docs/tasks/administer-cluster/manage-resources/quota-pod-namespace/)
409-
441+
* [为名字空间配置默认的内存请求和限制](/zh-cn/docs/tasks/administer-cluster/manage-resources/memory-default-namespace/)
442+
* [为名字空间配置默认的 CPU 请求和限制](/zh-cn/docs/tasks/administer-cluster/manage-resources/cpu-default-namespace/)
443+
* [为名字空间配置最小和最大内存限制](/zh-cn/docs/tasks/administer-cluster/manage-resources/memory-constraint-namespace/)
444+
* [为名字空间配置最小和最大 CPU 限制](/zh-cn/docs/tasks/administer-cluster/manage-resources/cpu-constraint-namespace/)
445+
* [为名字空间配置内存和 CPU 配额](/zh-cn/docs/tasks/administer-cluster/manage-resources/quota-memory-cpu-namespace/)
446+
* [为名字空间配置 Pod 配额](/zh-cn/docs/tasks/administer-cluster/manage-resources/quota-pod-namespace/)
410447
* [为 API 对象配置配额](/zh-cn/docs/tasks/administer-cluster/quota-api-object/)
411-
412448
* [控制节点上的拓扑管理策略](/zh-cn/docs/tasks/administer-cluster/topology-manager/)
413449

0 commit comments

Comments
 (0)