This guide explores in-place resizing of Pod resources to streamline updates and reduce downtime for stateful workloads without recreating the entire Pod.
In this guide, we explore how to perform in-place resizing of Pod resources—a feature that streamlines updates to resource changes without recreating the entire Pod. This innovative approach reduces downtime, especially for stateful workloads, by updating resource requirements directly on the running Pods.
By default, Kubernetes (v1.32 and later) replaces the existing Pod when you modify resource requests or limits in a Deployment. Consider the following deployment configuration:
When you update the resource requirements, Kubernetes terminates the existing Pod and creates a new one with the updated resource specifications. This behavior may lead to temporary service disruption.
To address the disruption from full Pod recreation, Kubernetes is developing an in-place update mechanism for Pod resources. This feature has been available in alpha since Kubernetes 1.27 and is not enabled by default. It is expected to transition to beta—and eventually be enabled by default—as it matures.
Below is an example where the CPU resource is increased from “250m” to “1”. Thanks to the in-place update feature, this change can be applied without deleting the Pod:
To activate this feature, enable the in-place Pod vertical scaling feature flag with the following command:
Copy
Ask AI
$ FEATURE_GATES=InPlacePodVerticalScaling=true
Once enabled, you can specify additional resize policy parameters to control restart behavior for each resource. For instance, a policy can ensure that updating CPU resources does not trigger a Pod restart, while memory updates might still require one.
When the in-place update feature is active, increasing the CPU resource value (for example, from “250m” to “1”) updates the running Pod directly without termination, ensuring smooth scalability and minimal service interruption.
The in-place resizing feature currently supports only CPU and memory resources. Familiarize yourself with these constraints before implementation.
It is important to note the following limitations with the current implementation of in-place resizing:
Only CPU and memory resources can be updated in place.
Changes to Pod QoS classes and certain other attributes are not supported.
Init containers and ephemeral containers are not eligible for in-place resizing.
Resource requests and limits, once assigned to a container, cannot be shifted to another container.
A container’s memory limit cannot be reduced below its current usage; if such a request is made, the resize operation will remain in progress until the new memory limit is achievable.
While this article focused on manually resizing Pod resources, Kubernetes also offers the Vertical Pod Autoscaler (VPA) to automate scaling based on resource usage. VPA continuously monitors your application’s resource consumption and adjusts requests and limits as needed, further reducing manual intervention.For more details on Kubernetes resource management, visit the Kubernetes Documentation or explore Kubernetes Basics.That’s it for this topic. Enjoy seamless in-place updates and improved resource scaling with Kubernetes!