Skip to content

Commit

Permalink
Documentation for in-place pod resize feature
Browse files Browse the repository at this point in the history
  • Loading branch information
vinaykul committed Mar 17, 2023
1 parent cee8ec7 commit b893d8b
Showing 1 changed file with 22 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ weight: 30

<!-- overview -->

THIS IS A PLACEHOLDER DOC - A WIP.

This page shows how to resize a CPU and memory resources assigned to containers
of a running pod without restarting the pod or its containers.

Kubernetes allocates resources on a node when a pod is started, and limits its
resource use based on requests and limits specified in the pod's containers.

A container's resource **requests** and **limits** are now **mutable** for CPU
Container's resource **requests** and **limits** are now **mutable** for CPU
and memory resource types. They now represent **desired** CPU and memory values.

This page assumes you are familiar with Quality of Service for Pods.
Expand All @@ -28,30 +26,27 @@ This page assumes you are familiar with Quality of Service for Pods.



<!-- steps -->


## Container Resize Policies

Resize policies allow for a more fine-grained control over how pod's containers
are resized for CPU and memory resource types. For example, the container's
application may be able to handle CPU resources resized while it continues to
run, but resizing memory limits may require that the container be restarted.

To enable this, container specification allows specifying **resizePolicy**.
The following container resize policies can be specified for CPU and memory:
* *RestartNotRequired*: Resize the container's resources while it is running.
* *Restart*: Restart the container and apply the new resources on restart.
To enable this, container specification allows users to specify **resizePolicy**.
The following restart policies can be specified for resizing CPU and memory:
* *NotRequired*: Resize the container's resources while it is running.
* *RestartContainer*: Restart the container and apply new resources on restart.

If resizePolicy is not specified, it defaults to *RestartNotRequired*.
If resizePolicy.restartPolicy is not specified, it defaults to *NotRequired*.

{{< note >}}
If the pod's restartPolicy is 'Never', resize policy must be set to RestartNotRequired
for all containers in the pod.
If the pod's restartPolicy is 'Never', container's resize restart policy must be
set to NotRequired for all containers in the pod.
{{< /note >}}

Below example shows a pod whose container's CPU can be resized live, but memory
resize memory requires that the container be restarted.
Below example shows a pod whose container's CPU can be resized without restart, but
memory resize memory requires container to be restarted.

```yaml
apiVersion: v1
Expand All @@ -64,10 +59,10 @@ spec:
- name: qos-demo-ctr
image: nginx
resizePolicy:
- policy: RestartNotRequired
resourceName: cpu
- policy: Restart
resourceName: memory
- resourceName: cpu
restartPolicy: NotRequired
- resourceName: memory
restartPolicy: RestartContainer
resources:
limits:
memory: "200Mi"
Expand All @@ -82,6 +77,8 @@ In the above example, if desired resources for both CPU and memory have changed,
the container will be restarted in order to resize its memory.
{{< /note >}}
<!-- steps -->
## Create a pod with resources
Expand Down Expand Up @@ -116,10 +113,10 @@ spec:
containers:
...
resizePolicy:
- policy: RestartNotRequired
resourceName: cpu
- policy: RestartNotRequired
resourceName: memory
- resourceName: cpu
policy: NotRequired
- resourceName: memory
policy: NotRequired
resources:
limits:
cpu: 700m
Expand All @@ -133,7 +130,7 @@ spec:
name: qos-demo-ctr
ready: true
...
resourcesAllocated:
allocatedResources:
cpu: 700m
memory: 200Mi
resources:
Expand Down Expand Up @@ -189,7 +186,7 @@ spec:
...
containerStatuses:
...
resourcesAllocated:
allocatedResources:
cpu: 800m
memory: 200Mi
resources:
Expand Down

0 comments on commit b893d8b

Please sign in to comment.