@@ -42,43 +42,62 @@ that has a different resource requirement.
42
42
[ 特性门控] ( /zh-cn/docs/reference/command-line-tools-reference/feature-gates/ ) 。
43
43
并让[ 工作负载控制器] ( /zh-cn/docs/concepts/workloads/controllers/ ) 创建一个具有不同资源需求的新 Pod。
44
44
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
+
45
52
<!--
46
53
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.
54
60
-->
55
61
对于原地调整 Pod 资源而言:
56
62
57
63
- 针对 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
+
61
69
<!--
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
63
71
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 .
66
74
- `InProgress`: This value indicates that the node has accepted the resize
67
75
request and is in the process of applying it to the pod's containers.
68
76
- `Deferred`: This value means that the requested resize cannot be granted at
69
77
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.
71
79
- `Infeasible`: is a signal that the node cannot accommodate the requested
72
80
resize. This can happen if the requested resize exceeds the maximum
73
81
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.
74
84
-->
75
85
- Pod 状态中 ` resize ` 字段显示上次请求待处理的调整状态。此字段可以具有以下值:
76
- - ` Proposed ` :此值表示请求调整已被确认,并且请求已被验证和记录 。
86
+ - ` Proposed ` :此值表示 Pod 大小已被调整,但 kubelet 还未处理此调整请求 。
77
87
- ` InProgress ` :此值表示节点已接受调整请求,并正在将其应用于 Pod 的容器。
78
88
- ` Deferred ` :此值意味着在此时无法批准请求的调整,节点将继续重试。
79
- 当其他 Pod 退出并释放节点资源时 ,调整可能会被真正实施。
89
+ 当其他 Pod 被移除并释放节点资源时 ,调整可能会被真正实施。
80
90
- ` Infeasible ` :此值是一种信号,表示节点无法承接所请求的调整值。
81
91
如果所请求的调整超过节点可分配给 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
+ 它是状态中所报告的实际请求。
82
101
83
102
## {{% heading "prerequisites" %}}
84
103
@@ -169,6 +188,35 @@ have changed, the container will be restarted in order to resize its memory.
169
188
170
189
<!-- steps -->
171
190
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
+
172
220
<!--
173
221
# # Create a pod with resource requests and limits
174
222
@@ -240,9 +288,6 @@ spec:
240
288
name: qos-demo-ctr-5
241
289
ready: true
242
290
...
243
- allocatedResources:
244
- cpu: 700m
245
- memory: 200Mi
246
291
resources:
247
292
limits:
248
293
cpu: 700m
@@ -284,7 +329,7 @@ Now, patch the Pod's Container with CPU requests & limits both set to `800m`:
284
329
现在对 Pod 的 Container 执行 patch 命令,将容器的 CPU 请求和限制均设置为 `800m`:
285
330
286
331
` ` ` 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"}}}]}}'
288
333
` ` `
289
334
290
335
<!--
@@ -315,9 +360,6 @@ spec:
315
360
...
316
361
containerStatuses:
317
362
...
318
- allocatedResources:
319
- cpu: 800m
320
- memory: 200Mi
321
363
resources:
322
364
limits:
323
365
cpu: 800m
@@ -330,18 +372,13 @@ spec:
330
372
` ` `
331
373
332
374
<!--
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,
339
378
indicating that container's CPU resources were resized without restarting the container.
340
379
-->
341
380
观察到 `allocatedResources` 的值已更新,反映了新的预期 CPU 请求。
342
- 这表明节点能够容纳提高后的 CPU 资源需求。
343
-
344
- 在 Container 状态中,更新的 CPU 资源值显示已应用新的 CPU 资源。
381
+ 这表明节点能够容纳提高后的 CPU 资源需求,而且新的 CPU 资源已经被应用。
345
382
Container 的 `restartCount` 保持不变,表示已在无需重启容器的情况下调整了容器的 CPU 资源。
346
383
347
384
<!--
@@ -365,13 +402,17 @@ kubectl delete namespace qos-example
365
402
* [Assign Memory Resources to Containers and Pods](/docs/tasks/configure-pod-container/assign-memory-resource/)
366
403
367
404
* [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/)
368
407
-->
369
408
# ## 对于应用开发人员
370
409
371
410
* [为容器和 Pod 分配内存资源](/zh-cn/docs/tasks/configure-pod-container/assign-memory-resource/)
372
411
373
412
* [为容器和 Pod 分配 CPU 资源](/zh-cn/docs/tasks/configure-pod-container/assign-cpu-resource/)
374
413
414
+ * [分配 Pod 级别的 CPU 和内存资源](/zh-cn/docs/tasks/configure-pod-container/assign-pod-level-resources/)
415
+
375
416
<!--
376
417
# ## For cluster administrators
377
418
0 commit comments