@@ -24,26 +24,33 @@ to be enabled. The alternative is to delete the Pod and let the
24
24
[ workload controller] ( /docs/concepts/workloads/controllers/ ) make a replacement Pod
25
25
that has a different resource requirement.
26
26
27
+ A resize request is made through the pod ` /resize ` subresource, which takes the full updated pod for
28
+ an update request, or a patch on the pod object for a patch request.
29
+
27
30
For in-place resize of pod resources:
28
- - Container's resource ` requests ` and ` limits ` are _ mutable_ for CPU
29
- and memory resources.
30
- - ` allocatedResources ` field in ` containerStatuses ` of the Pod's status reflects
31
- the resources allocated to the pod's containers.
32
- - ` resources ` field in ` containerStatuses ` of the Pod's status reflects the
33
- actual resource ` requests ` and ` limits ` that are configured on the running
34
- containers as reported by the container runtime.
35
- - ` resize ` field in the Pod's status shows the status of the last requested
31
+ - A container's resource ` requests ` and ` limits ` are _ mutable_ for CPU
32
+ and memory resources. These fields represent the _ desired_ resources for the container.
33
+ - The ` resources ` field in ` containerStatuses ` of the Pod's status reflects the resources
34
+ _ allocated_ to the pod's containers. For running containers, this reflects the actual resource
35
+ ` requests ` and ` limits ` that are configured as reported by the container runtime. For non-running
36
+ containers, these are the resources allocated for the container when it starts.
37
+ - The ` resize ` field in the Pod's status shows the status of the last requested
36
38
pending resize. It can have the following values:
37
- - ` Proposed ` : This value indicates an acknowledgement of the requested resize
38
- and that the request was validated and recorded .
39
+ - ` Proposed ` : This value indicates that a pod was resized, but the Kubelet has not yet processed
40
+ the resize .
39
41
- ` InProgress ` : This value indicates that the node has accepted the resize
40
42
request and is in the process of applying it to the pod's containers.
41
43
- ` Deferred ` : This value means that the requested resize cannot be granted at
42
44
this time, and the node will keep retrying. The resize may be granted when
43
- other pods leave and free up node resources.
45
+ other pods are removed and free up node resources.
44
46
- ` Infeasible ` : is a signal that the node cannot accommodate the requested
45
47
resize. This can happen if the requested resize exceeds the maximum
46
48
resources the node can ever allocate for a pod.
49
+ - ` "" ` : An empty or unset value indicates that the last resize completed. This should only be the
50
+ case if the resources in the container spec match the resources in the container status.
51
+
52
+ If a node has pods with an incomplete resize, the scheduler will compute the pod requests from the
53
+ maximum of a container's desired resource requests, and it's actual requests reported in the status.
47
54
48
55
49
56
## {{% heading "prerequisites" %}}
@@ -107,6 +114,21 @@ have changed, the container will be restarted in order to resize its memory.
107
114
108
115
<!-- steps -->
109
116
117
+ ## Limitations
118
+
119
+ In-place resize of pod resources currently has the following limitations:
120
+
121
+ - Only CPU and memory resources can be changed.
122
+ - Pod QoS Class cannot change. This means that requests must continue to equal limits for Guaranteed
123
+ pods, Burstable pods cannot set requests and limits to be equal for both CPU & memory, and you
124
+ cannot add resource requirements to Best Effort pods.
125
+ - Init containers and Ephemeral Containers cannot be resized.
126
+ - Resource requests and limits cannot be removed once set.
127
+ - A container's memory limit may not be reduced below its usage. If a request puts a container in
128
+ this state, the resize status will remain in ` InProgress` until the desired memory limit becomes
129
+ feasible.
130
+ - Windows pods cannot be resized.
131
+
110
132
111
133
# # Create a pod with resource requests and limits
112
134
@@ -159,9 +181,6 @@ spec:
159
181
name: qos-demo-ctr-5
160
182
ready: true
161
183
...
162
- allocatedResources:
163
- cpu: 700m
164
- memory: 200Mi
165
184
resources:
166
185
limits:
167
186
cpu: 700m
@@ -190,7 +209,7 @@ resources, you cannot change the QoS class in which the Pod was created.
190
209
Now, patch the Pod's Container with CPU requests & limits both set to `800m` :
191
210
192
211
` ` ` shell
193
- kubectl -n qos-example patch pod qos-demo-5 --patch '{"spec":{"containers":[{"name":"qos-demo-ctr-5", "resources":{"requests":{"cpu":"800m"}, "limits":{"cpu":"800m"}}}]}}'
212
+ 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"}}}]}}'
194
213
` ` `
195
214
196
215
Query the Pod's detailed information after the Pod has been patched.
@@ -215,9 +234,6 @@ spec:
215
234
...
216
235
containerStatuses:
217
236
...
218
- allocatedResources:
219
- cpu: 800m
220
- memory: 200Mi
221
237
resources:
222
238
limits:
223
239
cpu: 800m
@@ -229,12 +245,9 @@ spec:
229
245
started: true
230
246
` ` `
231
247
232
- Observe that the `allocatedResources` values have been updated to reflect the new
233
- desired CPU requests. This indicates that node was able to accommodate the
234
- increased CPU resource needs.
235
-
236
- In the Container's status, updated CPU resource values shows that new CPU
237
- resources have been applied. The Container's `restartCount` remains unchanged,
248
+ Observe that the `resources` in the `containerStatuses` have been updated to reflect the new desired
249
+ CPU requests. This indicates that node was able to accommodate the increased CPU resource needs,
250
+ and the new CPU resources have been applied. The Container's `restartCount` remains unchanged,
238
251
indicating that container's CPU resources were resized without restarting the container.
239
252
240
253
0 commit comments