Tttwigs
📖 Tutorial

How to Dynamically Scale Pod-Level Resources in Kubernetes v1.36

Last updated: 2026-05-01 05:40:02 Intermediate
Complete guide
Follow along with this comprehensive guide

Introduction

Kubernetes v1.36 introduces a powerful enhancement: in-place vertical scaling for pod-level resources is now Beta and enabled by default via the InPlacePodLevelResourcesVerticalScaling feature gate. This means you can adjust the aggregate resource budget of a running Pod instantly, often without restarting any containers. Whether you're managing complex sidecar patterns or need to handle traffic spikes, this guide walks you through everything from prerequisites to practical execution.

How to Dynamically Scale Pod-Level Resources in Kubernetes v1.36

What You Need

  • A Kubernetes cluster running v1.36 or later (with the feature gate enabled by default)
  • kubectl CLI configured to access your cluster
  • A running Pod that uses pod-level resource specs (.spec.resources) – containers should not have individual limits if you want them to share the pool
  • Basic familiarity with YAML and kubectl patch

Step-by-Step Guide

Step 1: Understand the Pod-Level Resource Model

In Kubernetes 1.36, you can define a shared resource pool at the Pod level instead of per-container. This is ideal for Pods with sidecars that don't need individual limits. The key fields are under spec.resources and spec.containers[].resources. When containers omit their own limits, they inherit the Pod-level budget.

Step 2: Create a Pod with Pod-Level Resources

Define a Pod YAML that sets limits only at the Pod level. Each container should specify a resizePolicy to control restart behaviour. Example:

apiVersion: v1
kind: Pod
metadata:
  name: shared-pool-app
spec:
  resources:
    limits:
      cpu: "2"
      memory: "4Gi"
  containers:
  - name: main-app
    image: my-app:v1
    resizePolicy:
    - resourceName: "cpu"
      restartPolicy: "NotRequired"
  - name: sidecar
    image: logger:v1
    resizePolicy:
    - resourceName: "cpu"
      restartPolicy: "NotRequired"

Apply it with kubectl apply -f pod.yaml.

Step 3: Trigger a Resize Using the Resize Subresource

To change the Pod-level resource allocation, use the resize subresource. The following command doubles the CPU limit from 2 to 4 without touching memory:

kubectl patch pod shared-pool-app --subresource resize --patch '{"spec":{"resources":{"limits":{"cpu":"4"}}}}'

This patch only modifies the aggregate budget. The Kubelet will then propagate the change to all containers that inherit limits.

Step 4: Understand Container Inheritance and ResizePolicy

The Kubelet treats the Pod-level resize as an event for every container that inherits its limits. To determine if a restart is needed, the Kubelet checks each container's resizePolicy:

  • Non-disruptive: If restartPolicy: NotRequired, the Kubelet attempts to update cgroup limits dynamically via the Container Runtime Interface (CRI) – no restart.
  • Disruptive: If restartPolicy: RestartContainer, the container is restarted to apply the new boundary safely.

Note: resizePolicy is not yet supported at the Pod level; it is defined per container.

Step 5: Verify the Resize and Monitor Node Stability

After patching, check the Pod's status: kubectl describe pod shared-pool-app. Look for the updated resource limits and restart counts. The Kubelet performs several safety checks before applying the change, including node feasibility and resource availability. If the new budget exceeds node capacity, the resize fails gracefully.

Step 6: Handle Edge Cases (Optional)

If your Pod contains a mix of containers – some with individual limits and some without – only the ones inheriting from the Pod level will be affected. Containers with explicit limits remain unchanged. You can also shrink the pool by reducing the values; ensure it doesn't go below current usage to avoid OOM kills.

Tips for Success

  • Start with NotRequired: Use restartPolicy: NotRequired for workloads that can tolerate cgroup updates without restarts – this makes scaling truly zero-downtime.
  • Test in non-production first: Always validate resize behaviour in a staging environment, especially if containers use stateful resources tied to cgroup limits.
  • Monitor resource pressure: Use kubectl top pod and cluster metrics to ensure your changes improve performance without overwhelming the node.
  • Leverage automation: Integrate resize patches with HPA or custom autoscalers to respond to real-time demand.
  • Remember the feature gate: In older clusters, you may need to enable InPlacePodLevelResourcesVerticalScaling manually. v1.36 enables it by default.

With this guide, you can confidently scale pod-level resources on the fly, keeping your applications responsive and your operations efficient.