OpsCanary
kubernetesautoscalingPractitioner

Mastering Resource Resizing for Kubernetes Containers

5 min read Kubernetes DocsAug 30, 2026Reviewed for accuracy
Share
PractitionerHands-on experience recommended

In the world of Kubernetes, resource management is crucial for maintaining application performance and cost efficiency. Resizing CPU and memory resources assigned to containers allows you to adapt to changing workloads dynamically. This capability is essential for ensuring that your applications have the necessary resources without over-provisioning, which can lead to wasted resources and increased costs.

You can request a resize by updating the desired requests and limits in the Pod's specification. This is typically done using kubectl patch, kubectl apply, or kubectl edit, targeting the Pod's resize subresource. When the desired resources don't match the allocated resources, the Kubelet will attempt to resize the container. It's important to note that the resizePolicy controls whether a container should be restarted during resizing. For instance, you can set it to NotRequired to avoid restarts or RestartContainer if you need the container to restart for the changes to take effect.

In production, ensure that the InPlacePodVerticalScaling feature gate is enabled across your control plane and nodes. Be aware of the implications of the restartPolicy on your Pods; if it's set to Never, then all container resizePolicy settings must be NotRequired. Additionally, if you enable the InPlacePodVerticalScalingSchedulerPreemption feature, the scheduler will monitor Pods with deferred resize statuses, which can affect scheduling behavior. This feature has been stable since Kubernetes v1.35, so make sure your cluster is running at least this version, and your kubectl client is at least v1.32 to use the --subresource=resize flag.

Key takeaways

  • Request a resize by updating the desired requests and limits in the Pod's specification.
  • Use `kubectl patch`, `kubectl apply`, or `kubectl edit` to target the Pod's resize subresource.
  • Set the `resizePolicy` to `NotRequired` to avoid container restarts during resizing.
  • Ensure the `InPlacePodVerticalScaling` feature gate is enabled for your cluster.
  • Check the `restartPolicy` of your Pods to avoid conflicts with container resizing.

Why it matters

Efficient resource management directly impacts application performance and cost savings in production environments. Properly resizing resources can lead to better resource utilization and improved application responsiveness.

Code examples

Bash
kubectl version
YAML
resizePolicy:-resourceName:cpurestartPolicy:NotRequired-resourceName:memoryrestartPolicy:RestartContainer

When NOT to use this

The official docs don't call out specific anti-patterns here. Use your judgment based on your scale and requirements.

Want the complete reference?

Read official docs

Test what you just learned

Quiz questions written from this article

Take the quiz →
Linux FoundationSponsor

Industry-standard certifications built by the people behind Linux and Kubernetes. Earn the CKA — the gold standard Kubernetes administrator cert. OpsCanary readers get 30% off year-round with code OPSCANARY3.

Get CKA certified →

Get the daily digest

One email. 5 articles. Every morning.

No spam. Unsubscribe anytime.