Skip to content

Commit 2b8a04f

Browse files
authored
Merge pull request #49035 from windsonsea/resizey
[zh] Sync resize-container-resources.md
2 parents 7e97a36 + ecf7d7e commit 2b8a04f

File tree

1 file changed

+73
-32
lines changed

1 file changed

+73
-32
lines changed

content/zh-cn/docs/tasks/configure-pod-container/resize-container-resources.md

Lines changed: 73 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -42,43 +42,62 @@ that has a different resource requirement.
4242
[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)
4343
并让[工作负载控制器](/zh-cn/docs/concepts/workloads/controllers/)创建一个具有不同资源需求的新 Pod。
4444

45+
<!--
46+
A resize request is made through the pod `/resize` subresource, which takes the full updated pod for
47+
an update request, or a patch on the pod object for a patch request.
48+
-->
49+
resize 请求通过 Pod 的 `/resize` 子资源发出,
50+
它会通过已完整更新的 Pod 来发出 update 请求,或对此 Pod 对象打补丁发出 patch 请求。
51+
4552
<!--
4653
For in-place resize of pod resources:
47-
- Container's resource `requests` and `limits` are _mutable_ for CPU
48-
and memory resources.
49-
- `allocatedResources` field in `containerStatuses` of the Pod's status reflects
50-
the resources allocated to the pod's containers.
51-
- `resources` field in `containerStatuses` of the Pod's status reflects the
52-
actual resource `requests` and `limits` that are configured on the running
53-
containers as reported by the container runtime.
54+
- A container's resource `requests` and `limits` are _mutable_ for CPU
55+
and memory resources. These fields represent the _desired_ resources for the container.
56+
- The `resources` field in `containerStatuses` of the Pod's status reflects the resources
57+
_allocated_ to the pod's containers. For running containers, this reflects the actual resource
58+
`requests` and `limits` that are configured as reported by the container runtime. For non-running
59+
containers, these are the resources allocated for the container when it starts.
5460
-->
5561
对于原地调整 Pod 资源而言:
5662

5763
- 针对 CPU 和内存资源的容器的 `requests``limits`**可变更的**
58-
- Pod 状态中 `containerStatuses``allocatedResources` 字段反映了分配给 Pod 容器的资源。
59-
- Pod 状态中 `containerStatuses``resources`
60-
字段反映了如同容器运行时所报告的、针对正运行的容器配置的实际资源 `requests``limits`
64+
这些字段表示容器所用的**预期**资源。
65+
- Pod 状态中 `containerStatuses``resources` 字段反映了分配给 Pod 容器的资源。
66+
对于正运行的容器,这反映了基于容器运行时的报告所配置的实际资源 `requests``limits`
67+
对于未运行的容器,这些是启动时为容器分配的资源。
68+
6169
<!--
62-
- `resize` field in the Pod's status shows the status of the last requested
70+
- The `resize` field in the Pod's status shows the status of the last requested
6371
pending resize. It can have the following values:
64-
- `Proposed`: This value indicates an acknowledgement of the requested resize
65-
and that the request was validated and recorded.
72+
- `Proposed`: This value indicates that a pod was resized, but the Kubelet has not yet processed
73+
the resize.
6674
- `InProgress`: This value indicates that the node has accepted the resize
6775
request and is in the process of applying it to the pod's containers.
6876
- `Deferred`: This value means that the requested resize cannot be granted at
6977
this time, and the node will keep retrying. The resize may be granted when
70-
other pods leave and free up node resources.
78+
other pods are removed and free up node resources.
7179
- `Infeasible`: is a signal that the node cannot accommodate the requested
7280
resize. This can happen if the requested resize exceeds the maximum
7381
resources the node can ever allocate for a pod.
82+
- `""`: An empty or unset value indicates that the last resize completed. This should only be the
83+
case if the resources in the container spec match the resources in the container status.
7484
-->
7585
- Pod 状态中 `resize` 字段显示上次请求待处理的调整状态。此字段可以具有以下值:
76-
- `Proposed`此值表示请求调整已被确认,并且请求已被验证和记录
86+
- `Proposed`此值表示 Pod 大小已被调整,但 kubelet 还未处理此调整请求
7787
- `InProgress`:此值表示节点已接受调整请求,并正在将其应用于 Pod 的容器。
7888
- `Deferred`:此值意味着在此时无法批准请求的调整,节点将继续重试。
79-
当其他 Pod 退出并释放节点资源时,调整可能会被真正实施。
89+
当其他 Pod 被移除并释放节点资源时,调整可能会被真正实施。
8090
- `Infeasible`:此值是一种信号,表示节点无法承接所请求的调整值。
8191
如果所请求的调整超过节点可分配给 Pod 的最大资源,则可能会发生这种情况。
92+
- `""`:留空或不设置,表示上一次调整已完成。
93+
只有容器规约中的资源与容器状态中的资源相匹配时,才会是这种情况。
94+
95+
<!--
96+
If a node has pods with an incomplete resize, the scheduler will compute the pod requests from the
97+
maximum of a container's desired resource requests, and it's actual requests reported in the status.
98+
-->
99+
如果节点有一些 Pod 还未完成调整,调度器将基于容器的预期资源请求的最大值来计算 Pod 请求,
100+
它是状态中所报告的实际请求。
82101

83102
## {{% heading "prerequisites" %}}
84103

@@ -169,6 +188,35 @@ have changed, the container will be restarted in order to resize its memory.
169188
170189
<!-- steps -->
171190
191+
<!--
192+
## Limitations
193+
194+
In-place resize of pod resources currently has the following limitations:
195+
-->
196+
## 限制 {#limitations}
197+
198+
<!--
199+
- Only CPU and memory resources can be changed.
200+
- Pod QoS Class cannot change. This means that requests must continue to equal limits for Guaranteed
201+
pods, Burstable pods cannot set requests and limits to be equal for both CPU & memory, and you
202+
cannot add resource requirements to Best Effort pods.
203+
- Init containers and Ephemeral Containers cannot be resized.
204+
- Resource requests and limits cannot be removed once set.
205+
- A container's memory limit may not be reduced below its usage. If a request puts a container in
206+
this state, the resize status will remain in `InProgress` until the desired memory limit becomes
207+
feasible.
208+
- Windows pods cannot be resized.
209+
-->
210+
- 仅 CPU 和内存资源可以被更改。
211+
- Pod QoS 类不能更改。这意味着 Guaranteed Pod 的 requests 必须继续等于其 limits,
212+
Burstable Pod 对于 CPU 和内存的 requests 不能设为等于其 limits,
213+
并且你不能给 BestEffort Pod 添加资源要求。
214+
- Init 容器和临时容器不能调整大小。
215+
- 资源请求和限制一旦被设置就不能移除。
216+
- 容器的内存限制不可以低于其使用量。如果某请求将容器置于此状态,
217+
调整的状态将停留在 `InProgress`,直到预期的内存限制成为可行为止。
218+
- Windows Pod 不能被调整大小。
219+
172220
<!--
173221
## Create a pod with resource requests and limits
174222

@@ -240,9 +288,6 @@ spec:
240288
name: qos-demo-ctr-5
241289
ready: true
242290
...
243-
allocatedResources:
244-
cpu: 700m
245-
memory: 200Mi
246291
resources:
247292
limits:
248293
cpu: 700m
@@ -284,7 +329,7 @@ Now, patch the Pod's Container with CPU requests & limits both set to `800m`:
284329
现在对 Pod 的 Container 执行 patch 命令,将容器的 CPU 请求和限制均设置为 `800m`:
285330

286331
```shell
287-
kubectl -n qos-example patch pod qos-demo-5 --patch '{"spec":{"containers":[{"name":"qos-demo-ctr-5", "resources":{"requests":{"cpu":"800m"}, "limits":{"cpu":"800m"}}}]}}'
332+
kubectl -n qos-example patch pod qos-demo-5 --subresource resize --patch '{"spec":{"containers":[{"name":"qos-demo-ctr-5", "resources":{"requests":{"cpu":"800m"}, "limits":{"cpu":"800m"}}}]}}'
288333
```
289334

290335
<!--
@@ -315,9 +360,6 @@ spec:
315360
...
316361
containerStatuses:
317362
...
318-
allocatedResources:
319-
cpu: 800m
320-
memory: 200Mi
321363
resources:
322364
limits:
323365
cpu: 800m
@@ -330,18 +372,13 @@ spec:
330372
```
331373

332374
<!--
333-
Observe that the `allocatedResources` values have been updated to reflect the new
334-
desired CPU requests. This indicates that node was able to accommodate the
335-
increased CPU resource needs.
336-
337-
In the Container's status, updated CPU resource values shows that new CPU
338-
resources have been applied. The Container's `restartCount` remains unchanged,
375+
Observe that the `resources` in the `containerStatuses` have been updated to reflect the new desired
376+
CPU requests. This indicates that node was able to accommodate the increased CPU resource needs,
377+
and the new CPU resources have been applied. The Container's `restartCount` remains unchanged,
339378
indicating that container's CPU resources were resized without restarting the container.
340379
-->
341380
观察到 `allocatedResources` 的值已更新,反映了新的预期 CPU 请求。
342-
这表明节点能够容纳提高后的 CPU 资源需求。
343-
344-
在 Container 状态中,更新的 CPU 资源值显示已应用新的 CPU 资源。
381+
这表明节点能够容纳提高后的 CPU 资源需求,而且新的 CPU 资源已经被应用。
345382
Container 的 `restartCount` 保持不变,表示已在无需重启容器的情况下调整了容器的 CPU 资源。
346383

347384
<!--
@@ -365,13 +402,17 @@ kubectl delete namespace qos-example
365402
* [Assign Memory Resources to Containers and Pods](/docs/tasks/configure-pod-container/assign-memory-resource/)
366403

367404
* [Assign CPU Resources to Containers and Pods](/docs/tasks/configure-pod-container/assign-cpu-resource/)
405+
406+
* [Assign Pod-level CPU and memory resources](/docs/tasks/configure-pod-container/assign-pod-level-resources/)
368407
-->
369408
### 对于应用开发人员
370409

371410
* [为容器和 Pod 分配内存资源](/zh-cn/docs/tasks/configure-pod-container/assign-memory-resource/)
372411

373412
* [为容器和 Pod 分配 CPU 资源](/zh-cn/docs/tasks/configure-pod-container/assign-cpu-resource/)
374413

414+
* [分配 Pod 级别的 CPU 和内存资源](/zh-cn/docs/tasks/configure-pod-container/assign-pod-level-resources/)
415+
375416
<!--
376417
### For cluster administrators
377418

0 commit comments

Comments
 (0)