AWS Builder Center
Kubernetes In-Place Pod Resizing - Vertical Scaling Without Downtime

Kubernetes In-Place Pod Resizing - Vertical Scaling Without Downtime

Traditionally, vertical scaling in Kubernetes meant deleting and recreating pods causing downtime and costly, especially for stateful or long-lived workloads. But with Kubernetes v1.33, in-place pod resizing allows live CPU and memory updates without restarts.

Introduction

In the world of cloud-native applications, agility and efficiency are paramount. Kubernetes has become the de facto standard for orchestrating containerized workloads, largely due to its robust autoscaling capabilities. While Kubernetes has long excelled at horizontal scaling, adjusting the number of pod replicas based on load, the vertical scaling (adjusting CPU and memory for individual pods) has historically presented a challenge.
Until now, changing pod resource allocations required deleting and recreating the pod, introducing unwanted downtime, disrupting stateful services, and impacting long-running or sensitive workloads.
With the release of Kubernetes v1.33, a significant step forward has arrived  In-Place Pod Resource Resizing 

What Is In-Place Pod Resource Resizing?

In-Place Pod Resizing is a Kubernetes feature that enables modifying the CPU and memory resource requests and limits of containers in a running pod, often without requiring a restart and provides fine-grained control over resource allocations, enabling dynamic tuning of workloads with minimal impact. Originally introduced as an alpha feature in Kubernetes v1.27, it graduated to beta in v1.33 and is now enabled by default.



Key Benefits

Reduced Disruption - Adjust the resources of live containers without needing to recreate them. This is a major win for:
  • Databases
  • Stream processors
  • Stateful microservices
  • Long-running workloads
Better Resource Efficiency - Avoid the cost of over-provisioning. Prevent instability from under-provisioning:
  • Scale up when needed
  • Scale down when possible
  • Improve node utilization and reduce costs
Responsive Scaling - Ideal for workloads with dynamic phases:
  • Burst during startup (e.g., JVM apps)
  • Scale down for steady state



How It Works Under the Hood

 The core mechanics of in-place pod resizing  involve a fundamental change in how Kubernetes handles container resource definitions:
Mutable Resource Fields - The  spec.containers[*].resources  field within a pod specification, which represents the desired resources for a container, is now mutable for CPU and memory. This means  spec.containers[*].resources  now represents the desired resources, while the actual active resources are reflected in  status.containerStatuses[*].resources .
Triggering a Resize - You can request a resize by updating the desired  requests  and  limits  in the pod's specification, typically using  kubectl patch  with the  --subresource resize  flag. The  kubelet  on the node detects this mismatch and attempts to apply the changes to the running container's  cgroups  through the container runtime.
# Resize CPU for container 'pause' using the new subresource
kubectl patch pod resize-demo --subresource resize --patch \
'{"spec":{"containers":[{"name":"pause", "resources":{"requests":{"cpu":"500m"}, "limits":{"cpu":"500m"}}}]}}'
Note: The  --subresource resize  command line argument requires kubectl client version v1.32.0 or later. Older versions will report an invalid subresource error.

Monitoring Pod Resources After Resizing

Once a pod has been resized, Kubernetes provides detailed status fields to help you track the current resource state and understand the impact of the change. These fields are available in the  containerStatuses  section of the Pod status.
Here's a breakdown of the most relevant fields:
  •  allocatedResources  This field shows the resource values (CPU, memory) that were confirmed by the kubelet for scheduling purposes. It represents the desired/target resource configuration after a resize request has been accepted.
  •  resources  This new field (available in  status.containerStatuses[*].resources ) reflects the currently active resources that have been successfully applied to the container's cgroups. It provides a real-time view of what the container is actually running with.
  •  restartCount  Use this to determine if a resize operation triggered a container restart—especially relevant when using  resizePolicy: RestartContainer  (e.g., for memory changes). It also helps validate that your  resizePolicy  behavior is working as intended.
kubectl get pod resize-demo -oyaml


Container Resize Policies

Kubernetes provides fine-grained control over whether a container should restart when resized through the  resizePolicy  field:
 NotRequired  (Default): The resource change is applied to the running container without restarting it. This is generally suitable for CPU changes.
 RestartContainer : The container is restarted to apply the new resource values. This is often necessary for memory changes, as many applications cannot dynamically adjust their memory allocation. If both CPU and memory are changed simultaneously and memory requires a restart, the container will restart
# Example pod with resizePolicy configuration
apiVersion: v1
kind: Pod
metadata:
name: resize-demo
spec:
containers:
- name: pause
image: registry.k8s.io/pause:3.8
resizePolicy:
- resourceName: cpu
restartPolicy: NotRequired # Default, but explicit here
- resourceName: memory
restartPolicy: RestartContainer
resources:
limits:
memory: "200Mi"
cpu: "700m"
requests:
memory: "200Mi"
cpu: "700m"

Monitoring Resize Status

You can use  kubectl describe pod  command to monitor the status of a resize request through new pod conditions:
 PodResizePending : Indicates the  kubelet  cannot immediately grant the request. This could be because the request is  Infeasible  (e.g., requesting more resources than the node has) or  Deferred  (the  kubelet  needs to wait for resources to be freed up and will retry).
 PodResizeInProgress : Indicates the  kubelet  has accepted the request and is applying the changes.

You can also track resource changes via  status.containerStatuses  fields like  allocatedResources  and  restartCount 

Enhanced VPA Integration

The  Vertical Pod Autoscaler  (VPA) is a Kubernetes add-on designed to automatically adjust CPU and memory requests for your pods based on actual usage patterns. While VPA has been highly effective at providing resource recommendations, its historical limitation was that applying these recommendations often required a pod restart. With the introduction of in-place pod resizing, VPA can now leverage this new capability. Work is currently underway in the Kubernetes community to enhance VPA with a planned new update mode called   InPlaceOrRecreate  . This mode will instruct VPA to first attempt to resize the pod in-place. If an in-place resize is not possible for any reason, it will then fall back to recreating the pod. This integration can significantly reduce disruption and make VPA a much more viable option for a wider range of applications. On upgrade of the VPA to 1.4.0 users can use the new  InPlaceOrRecreate  by enabling the alpha Feature Gate (which defaults to disabled) by passing  --feature-gates=InPlaceOrRecreate=true  to the updater and admission-controller components and setting their VPA UpdateMode to use  InPlaceOrRecreate .
⚠️ Note: As of VPA v1.4.0,  InPlaceOrRecreate  is an alpha feature and requires enabling the appropriate feature gate. Use with caution in production environments.
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: sample-app
spec:
targetRef:
apiVersion: "apps/v1"
kind: Deployment
name: sample-app
updatePolicy:
updateMode: "InPlaceOrRecreate"
resourcePolicy:
containerPolicies:
- containerName: nginx
minAllowed:
cpu: "500m"
memory: "512Mi"
maxAllowed:
cpu: "2"
memory: "2Gi"



Conclusion

Kubernetes v1.33's graduation of in-place pod resizing to beta marks a significant leap forward for vertical scaling in Kubernetes. This feature addresses a long standing challenge by enabling non disruptive resource adjustments, fostering greater efficiency, improved performance, and optimized cost management for your containerized applications. Start experimenting with this new capability in your non production environments to see how it can bring smoother scaling and a more responsive Kubernetes experience.

References

Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article