How to Resize Kubernetes Pods Without a Restart

Short answer: Yes, you can change a running pod’s CPU and memory without recreating it. In-place pod resize has been a stable Kubernetes feature since v1.35, so on a current cluster you run kubectl patch pod <name> --subresource resize with the new requests and limits, and the kubelet applies them to the running container. Whether the container restarts depends on the resizePolicy you set for CPU and memory.

For years, changing resources in Kubernetes meant one thing: kill the pod and start a new one. That is fine for stateless web apps behind a load balancer, but painful for a database replica that takes 20 minutes to warm its cache, a long batch job, or a pod you are firefighting during an incident. This guide shows how in-place resize works, the exact commands, how to check that the change actually landed, and the mistakes that trip people up in real clusters.

What is in-place pod resize?

In-place pod resize (the feature gate was called InPlacePodVerticalScaling) lets you edit the CPU and memory requests and limits of containers in a pod that is already running. It first appeared as alpha in Kubernetes v1.27 and graduated to stable in v1.35. In stable releases the feature is locked on, so you cannot switch it off, and setting the old feature gate has no effect.

Three fields matter when you work with it:

  • Desired resources – spec.containers[*].resources. This is what you ask for.
  • Actual resources – status.containerStatuses[*].resources. This is what is really configured on the running container right now. Always check this field, not the spec, to confirm a resize worked.
  • Allocated resources – status.containerStatuses[*].allocatedResources. Values the kubelet has accepted, mostly used internally for scheduling.

While a resize is pending or in progress, the scheduler counts the highest of the desired, allocated and actual requests for that node, so a pending upsize already reserves room and the scheduler does not overpack the node.

Before you begin: version checks

You need two things:

  1. A recent cluster. The official task guide targets server version 1.33 or later, and the feature is GA from 1.35. On Amazon EKS, version 1.35 has been available since January 27, 2026, with standard support running until March 27, 2027, according to the EKS version calendar.
  2. kubectl v1.32 or newer. The --subresource resize flag needs a v1.32+ client. An older kubectl fails with an invalid subresource error, which confuses a lot of people who have a new cluster but an old laptop binary.
kubectl version
# Check both "Client Version" and "Server Version"

One more practitioner check: resizing goes through a separate subresource, so your RBAC role needs permission for it. Test it before an incident, not during one:

kubectl auth can-i patch pods --subresource=resize -n my-namespace

Step-by-step: resize a pod’s CPU without a restart

Step 1: Create a namespace and a test pod

Create a sandbox namespace so you do not touch real workloads:

kubectl create namespace resize-lab

Save this manifest as resize-lab.yaml. It sets CPU to resize live and memory to restart the container (more on why below):

apiVersion: v1
kind: Pod
metadata:
  name: api-worker
  namespace: resize-lab
spec:
  containers:
  - name: app
    image: registry.k8s.io/pause:3.8
    resizePolicy:
    - resourceName: cpu
      restartPolicy: NotRequired
    - resourceName: memory
      restartPolicy: RestartContainer
    resources:
      requests:
        cpu: "500m"
        memory: "256Mi"
      limits:
        cpu: "500m"
        memory: "256Mi"
kubectl apply -f resize-lab.yaml
kubectl get pod api-worker -n resize-lab

Because requests equal limits for both CPU and memory, this pod lands in the Guaranteed QoS class. Remember that, because it limits what you can change later.

Step 2: Patch the CPU through the resize subresource

Raise CPU from 500m to 750m. Since the pod is Guaranteed, change the request and the limit together:

kubectl patch pod api-worker -n resize-lab --subresource resize --patch \
  '{"spec":{"containers":[{"name":"app","resources":{"requests":{"cpu":"750m"},"limits":{"cpu":"750m"}}}]}}'

You can also use kubectl edit pod api-worker -n resize-lab --subresource resize, or a server-side apply with --subresource resize if you keep the manifest in a file.

Step 3: Confirm the change actually applied

Do not trust the spec alone. Read the actual resources and the restart count:

kubectl get pod api-worker -n resize-lab \
  -o jsonpath='{.status.containerStatuses[0].resources}{"\n"}{.status.containerStatuses[0].restartCount}{"\n"}'

You should see cpu: 750m in the status and a restart count of 0, because the CPU policy is NotRequired.

Step 4: Resize memory and watch the restart

kubectl patch pod api-worker -n resize-lab --subresource resize --patch \
  '{"spec":{"containers":[{"name":"app","resources":{"requests":{"memory":"384Mi"},"limits":{"memory":"384Mi"}}}]}}'

This time the restart count goes up by one. The pod object, its IP, its node and its volumes stay the same, but the container process restarts because memory uses RestartContainer. That is still much cheaper than a full reschedule: no new image pull on another node, no new pod IP, no re-attach of persistent volumes.

Step 5: Clean up

kubectl delete namespace resize-lab

Choosing a resizePolicy: NotRequired vs RestartContainer

Each container can set a resizePolicy per resource:

PolicyWhat happens on resizeGood fit
NotRequired (default)New values are applied to the running container with no restartCPU for almost everything; memory for apps that read cgroup limits dynamically
RestartContainerThe container restarts so the new values take effectMemory for JVM, Node.js, .NET and anything that sizes its heap at startup

If you change both CPU and memory in one patch and either policy is RestartContainer, the container restarts. If you leave the field out, the default is NotRequired.

Tip from the field: giving a Java service more memory with NotRequired often does nothing useful. The JVM fixed its maximum heap (from -Xmx or a percentage of the container limit) when it started, so the extra memory sits unused until the next restart. For these runtimes, set memory to RestartContainer and be honest with yourself that a memory resize means a restart.

One rule to remember: if a pod’s top-level restartPolicy is Never, every container resize policy must be NotRequired. Kubernetes rejects a policy that would need a restart in such pods.

How to tell if a resize is stuck

The kubelet reports resize progress through pod conditions:

  • PodResizePending with reason Infeasible – the node can never satisfy the request (for example, you asked for more CPU than the node has). Patch again with sane values.
  • PodResizePending with reason Deferred – not possible right now, but it might be later, such as after another pod leaves the node. The kubelet keeps retrying.
  • PodResizeInProgress – accepted and being applied. Errors during this phase show up with reason Error and a message.

A quick way to check:

kubectl get pod api-worker -n resize-lab \
  -o jsonpath='{range .status.conditions[*]}{.type}={.reason} {.message}{"\n"}{end}'

When several deferred resizes are waiting on a node, the kubelet retries them by PriorityClass first, then Guaranteed pods before Burstable ones, then the ones that have waited longest. Since v1.35 you can also compare the pod’s status.observedGeneration with metadata.generation to see whether the kubelet has processed your latest resize request.

Kubernetes v1.37 adds an alpha option (feature gate InPlacePodVerticalScalingSchedulerPreemption, off by default) that lets the scheduler evict lower-priority pods to make room for a higher-priority pod’s deferred resize. Treat it as experimental and leave it off in production until it matures.

Limitations you must know

The official limitations list is short but important:

  • Only CPU and memory can be resized. GPUs, ephemeral storage and other resources cannot.
  • QoS class is fixed. A Guaranteed pod must keep requests equal to limits; a Burstable pod cannot make requests equal limits for both CPU and memory at once; a BestEffort pod cannot gain requests or limits. This is the most common “why was my patch rejected?” answer.
  • Memory decreases are best effort. With NotRequired, the kubelet skips a memory-limit decrease if current usage is above the new limit, and the resize stays “in progress”. There is still a small race if usage spikes right after the check, so shrink memory during quiet periods.
  • No removing resources. Once requests or limits are set, you can change them but not delete them.
  • Container types: ephemeral containers cannot be resized; sidecar containers can; non-restartable init containers can be resized while running but cannot use RestartContainer.
  • No Windows pods.
  • Static CPU or Memory manager policies on the node block in-place resize for those pods.
  • Swap: pods using swap can only resize memory requests if the memory policy is RestartContainer.

Also new in v1.37 as alpha: the resize subresource can change the sizeLimit of memory-backed emptyDir volumes, behind the InPlacePodVerticalScalingMemoryBackedVolumes gate and only on cgroup v2 nodes.

The Deployment trap: your resize will not survive a rollout

This is an easy mistake to make. In-place resize patches the pod, not the Deployment, StatefulSet or Helm values that created it. The moment someone runs a rollout, scales out or a node gets drained, the new pods come up with the old template values.

Use in-place resize as a fast fix, then make it permanent:

  1. Patch the hot pods in place to stop the bleeding (CPU throttling, memory pressure).
  2. Update the resources in the Deployment manifest, Helm chart or Kustomize overlay in Git.
  3. Let your normal pipeline or GitOps tool roll that out at a calm moment.

Note that editing resources in a Deployment’s pod template still triggers a normal rolling update with new pods. In-place resize only applies when you target the running pod’s resize subresource, or when an autoscaler does it for you.

Automating it with the Vertical Pod Autoscaler

Patching pods by hand does not scale. The Vertical Pod Autoscaler (VPA) can now use in-place resize instead of evicting pods. You choose the behavior with spec.updatePolicy.updateMode:

VPA modeWhat it doesWhen to use it
OffOnly calculates recommendations in the VPA statusRight-sizing reviews and FinOps reports
InitialSets requests only when pods are createdWorkloads that must never change while running
RecreateEvicts pods so they come back with new requestsStateless apps that tolerate restarts
InPlaceOrRecreateTries in-place resize first, falls back to eviction if it cannotMost production services; the best default today
InPlaceOnly resizes in place; never evicts, waits and retries insteadStateful or slow-starting pods where eviction is worse than waiting

The old Auto mode is deprecated since VPA 1.4.0 and behaves the same as Recreate, so update older manifests. A minimal example:

apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: api-vpa
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: api
  updatePolicy:
    updateMode: "InPlaceOrRecreate"

Two practical notes. First, if your containers use RestartContainer for memory, a VPA memory change still restarts them, and on managed platforms like GKE that policy can also push VPA back to re-creation. Second, do not let VPA and a CPU-based Horizontal Pod Autoscaler fight over the same metric on the same workload; pick one to own CPU.

When to use which approach

SituationBest option
Incident: one pod is CPU-throttled right nowManual in-place resize, then fix the manifest in Git
Steady right-sizing for long-running servicesVPA in InPlaceOrRecreate mode
Traffic spikes that need more replicasHorizontal Pod Autoscaler
Slow-start Java or database podsVPA InPlace mode, or manual CPU resize with memory set to restart
Startup needs extra CPU, then lessTemporarily raise CPU in place, lower it once the pod is Ready

That last pattern is worth calling out for teams watching cloud bills. Many services ask for big CPU requests only because startup is slow; resizing down after warm-up can free real capacity on your nodes. If cost control is on your plate, our guide to FinOps for cloud cost control covers how to turn this kind of right-sizing into a habit.

Common mistakes and how to avoid them

  • Old kubectl: “invalid subresource” almost always means your client is older than v1.32.
  • Patching the spec without the subresource: a plain kubectl patch pod on resources is rejected. Always add --subresource resize.
  • Breaking the QoS class: changing only the CPU request on a Guaranteed pod fails because requests would no longer equal limits. Change both.
  • Checking the wrong field: the spec shows what you asked for; status.containerStatuses[*].resources shows what you got.
  • Forgetting the template: the next rollout silently reverts your manual fix.
  • Typing cores instead of millicores: "1000" means 1,000 cores, not one core. You will get an Infeasible condition.

Where to go next

If you are new to the platform, start with our Kubernetes basics guide. For the wider toolchain around clusters (CI/CD, IaC, monitoring), see our list of DevOps tools every team should know, and if you are planning your career path from DevOps toward platform or AI engineering, the developer career roadmap shows how skills like this fit in.

FAQ

Which Kubernetes version supports in-place pod resize?

The feature first appeared as alpha in v1.27 and became stable (GA) in v1.35. The official task guide requires a server on v1.33 or later, and you need kubectl v1.32 or later for the --subresource resize flag.

Does resizing memory restart the container?

Only if the container’s memory resizePolicy is RestartContainer. With the default NotRequired, memory is changed live, but many runtimes (such as the JVM) will not use extra memory until they restart, so a restart policy is often the safer choice.

Can I resize a pod managed by a Deployment?

Yes, you can patch the running pod’s resize subresource. But the Deployment template is unchanged, so new pods from the next rollout or scale-out will use the old values. Update the Deployment (or Helm values) as well.

Why is my resize stuck in PodResizePending?

Check the condition’s reason. Infeasible means the node can never fit the request, so lower it. Deferred means the node is busy right now and the kubelet will retry when capacity frees up.

Does the Vertical Pod Autoscaler use in-place resize?

Yes. Set updateMode to InPlaceOrRecreate to try in-place first with eviction as a fallback, or to InPlace if you never want VPA to evict pods.

Leave a Comment

WP2Social Auto Publish Powered By : XYZScripts.com