Skip to content

Commit 33d7b0c

Browse files
authored
Merge pull request #98484 from mburke5678/node-in-place-update
OSDOCS16065 Document InPlacePod Resize feature for OpenShift 4.20
2 parents 9afe5ed + 734307e commit 33d7b0c

File tree

4 files changed

+224
-0
lines changed

4 files changed

+224
-0
lines changed

_topic_maps/_topic_map.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2643,6 +2643,8 @@ Topics:
26432643
File: nodes-pods-autoscaling
26442644
- Name: Automatically adjust pod resource levels with the vertical pod autoscaler
26452645
File: nodes-pods-vertical-autoscaler
2646+
- Name: Manually adjust pod resource levels
2647+
File: nodes-pods-adjust-resources-in-place
26462648
- Name: Providing sensitive data to pods by using secrets
26472649
File: nodes-pods-secrets
26482650
- Name: Providing sensitive data to pods by using an external secrets store
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * nodes/pods/nodes-pods-adjust-resources-in-place.adoc
4+
5+
:_mod-docs-content-type: REFERENCE
6+
[id="nodes-pods-adjust-resources-in-place-about_{context}"]
7+
= About in-place pod resizing
8+
9+
In-place pod resizing allows you to change the CPU and memory resources for containers within a running pod without application disruption. The standard methods for changing pod CPU and memory resources cause the pod to be re-created, potentially causing disruption. In-place pod resizing allows you to scale pod resources up or down without suffering the downtime or state loss associated with a pod restart.
10+
11+
When using in-place pod resizing to change CPU or memory resources, you can control whether a pod is restarted by configuring a resize policy in the pod specification. The following example resize policy requires a pod restart upon changing the memory resources, but prevents a restart for CPU resource changes.
12+
13+
.Example resource policy
14+
[source,yaml]
15+
----
16+
apiVersion: v1
17+
kind: Pod
18+
metadata:
19+
name: resize-demo
20+
spec:
21+
securityContext:
22+
runAsNonRoot: true
23+
seccompProfile:
24+
type: RuntimeDefault
25+
containers:
26+
- name: pause
27+
# ...
28+
resizePolicy: <1>
29+
- resourceName: cpu
30+
restartPolicy: NotRequired
31+
- resourceName: memory
32+
restartPolicy: RestartContainer
33+
----
34+
<1> Specifies a resize policy.
35+
36+
[NOTE]
37+
====
38+
Memory limits cannot be decreased unless the resize policy for `memory` is `RestartContainer`.
39+
====
40+
41+
You cannot add or modify a resize policy to an existing pod, but you can add or edit the policy in the pod's owner object, such as a deployment, if the pod has an owner object.
42+
43+
Using in-place pod resizing requires that you use the `--subresource resize` flag when editing a pod in the {oc-first}, as shown in the following examples:
44+
45+
.Example commands
46+
[source,terminal]
47+
----
48+
$ oc edit pod <pod_name> --subresource resize
49+
----
50+
51+
[source,terminal]
52+
----
53+
$ apply -f <file_name>.yaml --subresource resize
54+
----
55+
56+
[source,terminal]
57+
----
58+
$ patch pod <pod_name> --subresource resize --patch \
59+
'{"spec":{"containers":[{"name":"pause", "resources":{"requests":{"cpu":"800m"}, "limits":{"cpu":"800m"}}}]}}'
60+
----
61+
62+
Because you need to use the `--subresource resize` flag with a resize policy, you cannot edit the pod resources in the {product-title} web console.
63+
64+
If the resize policy is `NotRequired` and you change the request or limits, the pod is not restarted.
65+
66+
[source,terminal]
67+
----
68+
$ oc get pods
69+
----
70+
71+
.Example output
72+
[source,terminal]
73+
----
74+
NAME READY STATUS RESTARTS AGE
75+
resize-pod 1/1 Running 0 5s
76+
----
77+
78+
If the resize policy is `RestartContainer` and you change the request or limits, the pod is restarted.
79+
80+
[source,terminal]
81+
----
82+
$ oc get pods
83+
----
84+
85+
.Example output
86+
[source,terminal]
87+
----
88+
NAME READY STATUS RESTARTS AGE
89+
resize-pod 1/1 Running 1 (5s ago) 5s
90+
----
91+
92+
After making the resource changes, the pod status conditions indicate the state of a resize request by using the following messages:
93+
94+
* `PodResizeInProgress`: The kubelet is able to allocate the requested resources and the change is being applied.
95+
* `PodResizePending`: The kubelet cannot immediately make the change for one of the following reasons:
96+
** `Infeasible`: The requested resize cannot be executed on the current node. For example, requesting more resources than the node has available would result in an `Infeasible` condition.
97+
** `Deferred`: The requested resize is currently not possible, but might become possible at a later time. For example, if another pod is removed from the node, the requested resources might become available. The kubelet retries the resize when conditions on the node change.
98+
* `Error`: The kubelet is experiencing an error during the resource allocation and reports the reason for the error in the message field.
99+
100+
.Example status for an infeasible change
101+
[source,yaml]
102+
----
103+
apiVersion: v1
104+
kind: Pod
105+
metadata:
106+
name: resize-demo
107+
# ...
108+
status:
109+
conditions:
110+
- lastProbeTime: "2025-09-03T15:00:50Z"
111+
lastTransitionTime: "2025-09-03T15:00:50Z"
112+
message: 'Node didn''t have enough capacity: cpu, requested: 1000000, capacity:
113+
3500'
114+
reason: Infeasible
115+
status: "True"
116+
type: PodResizePending
117+
----
118+
119+
Note the following limitations:
120+
121+
* In-place pod resizing is not supported for non-restartable init containers and ephemeral containers.
122+
* In-place pod resizing is not allowed if the changes violate other pod mutability constraints, such as the pod QoS class.
123+
* Pods managed by a static `cpuManagerPolicy` or `memoryManagerPolicy` parameter cannot be resized with in-place pod resizing.
124+
* Pods utilizing swap memory must use the `RestartContainer` policy for memory requests with in-place pod resizing.
125+
// Above Notes taken from https://kubernetes.io/docs/tasks/configure-pod-container/resize-container-resources/#limitations
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * nodes/pods/nodes-pods-adjust-resources-in-place.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="nodes-pods-adjust-resources-in-place-configuring_{context}"]
7+
= Configuring in-place pod resizing
8+
9+
In-place pod resizing requires that you add a resize policy to a pod specification.
10+
11+
You cannot add or modify a resize policy in an existing pod, but you can add or edit the policy in the pod's owner object, such as a deployment, if the pod has an owner object.
12+
13+
.Procedure
14+
15+
. Create a pod spec with a resize policy or add a resize policy to the owner object of an existing pod:
16+
17+
.. Create a YAML file similar to the following example:
18+
+
19+
[source,yaml]
20+
----
21+
apiVersion: v1
22+
kind: Pod
23+
metadata:
24+
name: resize-pod
25+
spec:
26+
# ...
27+
containers:
28+
- name: pause
29+
resizePolicy: <1>
30+
- resourceName: cpu
31+
restartPolicy: NotRequired
32+
- resourceName: memory
33+
restartPolicy: RestartContainer
34+
# ...
35+
----
36+
<1> Specifies a resize policy. For CPU and/or memory resources specify one of the following values:
37+
+
38+
* `NotRequired`: Apply any resource changes without restarting the pod. This is the default when using a resize policy.
39+
* `RestartContainer`: Apply any resource changes and restart the pod.
40+
41+
.. Create the object by running a command similar to the following:
42+
+
43+
[source,terminal]
44+
----
45+
$ oc create -f <file_name>.yaml
46+
----
47+
48+
.Verification
49+
50+
* Check that the resize policy is applied by modifying the CPU or memory requests or limits by running a command similar to the following. You must include the `--subresource resize` flag. If the pod has a owner object, such as a deployment, you must edit the owner object.
51+
+
52+
[source,terminal]
53+
----
54+
$ oc edit pod <pod_name> --subresource resize
55+
----
56+
+
57+
If the policy is applied, the pod responds as expected.
58+
+
59+
[source,terminal]
60+
----
61+
$ oc get pods
62+
----
63+
+
64+
If the resize policy is `NotRequired`, the pod is not restarted.
65+
+
66+
.Example output
67+
[source,terminal]
68+
----
69+
NAME READY STATUS RESTARTS AGE
70+
resize-pod 1/1 Running 0 5s
71+
----
72+
+
73+
If the resize policy is `RestartContainer`, the pod is restarted.
74+
+
75+
.Example output
76+
[source,terminal]
77+
----
78+
NAME READY STATUS RESTARTS AGE
79+
resize-pod 1/1 Running 1 (5s ago) 5s
80+
----
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
:_mod-docs-content-type: ASSEMBLY
2+
:context: nodes-pods-adjust-resources-in-place
3+
[id="nodes-pods-adjust-resources-in-place"]
4+
= Adjust pod resource levels without pod disruption
5+
include::_attributes/common-attributes.adoc[]
6+
7+
toc::[]
8+
9+
You can change the CPU or memory resource requests and limits assigned to a container without re-creating or restarting the pod by using _in-place pod resizing_.
10+
11+
include::modules/nodes-pods-adjust-resources-in-place-about.adoc[leveloffset=+1]
12+
13+
include::modules/nodes-pods-adjust-resources-in-place-configuring.adoc[leveloffset=+1]
14+
15+
[role="_additional-resources"]
16+
== Additional resources
17+
* xref:../../nodes/pods/nodes-pods-using.adoc#nodes-pods-understanding-requests-limits_nodes-pods-using-ssy[Understanding resource requests and limits]

0 commit comments

Comments
 (0)