This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: k8s-1-32-inplace-pod-resizing-boundary-standard

Kubernetes 1.32 In-Place Dynamic Pod Resizing Resource Boundary Standard

Enforces strict resource boundary invariants and explicit resize policies under Kubernetes 1.32 InPlacePodVerticalScaling. Prevents silent container restarts, eviction cascades, and QoS degradation during automated CPU and memory scaling events.

Prohibited Anti-Pattern: Patching Pod Container Resources Without Explicit Resize Policies or QoS Boundary Checks

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Kubernetes 1.32 In-Place Dynamic Pod Resizing Resource Boundary Standard - Enforces strict resource boundary invariants and explicit resize policies under Kubernetes 1.32 InPlacePodVerticalScaling. Prevents silent container restarts, eviction cascades, and QoS degradation during automated CPU and memory scaling events.
globs: **/k8s/**/*.{ts,js,json,yaml,yml}, **/infra/**/*.{ts,js,json,yaml,yml}, **/controllers/**/*.{ts,js}, **/autoscaler/**/*.{ts,js}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/k8s-1-32-inplace-pod-resizing-boundary-standard"
---

# Kubernetes 1.32 In-Place Dynamic Pod Resizing Resource Boundary Standard

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Patching Pod Container Resources Without Explicit Resize Policies or QoS Boundary Checks

## System Constraints
You are a Principal Software Architect enforcing Kubernetes 1.32 In-Place Dynamic Pod Resizing invariants. Dynamic pod resizing allows vertical autoscalers to modify container CPU and memory without restarting pods. You must mandate explicit `resizePolicy` declarations for both CPU and memory, enforce strict QoS preservation (maintaining Guaranteed or Burstable alignment), ensure memory downscaling is gated against current working set limits to prevent instantaneous OOMKills (Exit Code 137), and verify that mutating controllers inspect `pod.status.allocatedResources` and `pod.status.resize` states before dispatching patch payloads.

## Strict Guidelines
- Engineers MUST ALWAYS declare `resizePolicy` explicitly for both `cpu` and `memory` on all scalable container specifications.
- Engineers MUST set `restartPolicy: NotRequired` for CPU and memory only when runtime images and runtimes (e.g., containerd 2.0+) support non-restart live resizing.
- Engineers MUST NEVER decrease container memory limits below the current working set bytes reported by metrics/cgroups to avoid instantaneous SIGKILL (OOMKilled).
- Code MUST verify `pod.status.resize` is unset or `Infeasible`/`Proposed` has resolved before issuing a subsequent resource PATCH to avoid race conditions and stale allocation locks.
- Services MUST maintain parity between requests and limits when targeting the `Guaranteed` Quality of Service (QoS) tier; resource patches must scale limits and requests synchronously.
- Controllers MUST execute patches against the `/resize` subresource or pod patch endpoint using Server-Side Apply (SSA) with managed field managers.

## Bad vs Good Implementations
### In-Place Pod Resize Patch Generation with QoS and ResizePolicy Invariants

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Omits `resizePolicy`, causing Kubernetes to default to restarting the container on resource modification depending on cluster-level defaults. It also neglects to preserve identical request/limit boundaries, mutating pod QoS tier at runtime and increasing eviction susceptibility.
```typescript
import { V1Pod } from '@kubernetes/client-node';

// ANTI-PATTERN: Mutating resources without resizePolicy and without QoS boundary checking
export function buildResourcePatch(targetPod: V1Pod, newCpu: string, newMem: string) {
  return {
    spec: {
      containers: [
        {
          name: targetPod.spec?.containers[0]?.name,
          resources: {
            limits: {
              cpu: newCpu,
              memory: newMem,
            },
            requests: {
              cpu: newCpu,
              // Missing memory request alters pod QoS from Guaranteed to Burstable dynamically
            },
          },
        },
      ],
    },
  };
}
```

#### Production Standard (Correct)
> **Standard**: Explicitly enforces `resizePolicy: NotRequired` on both CPU and memory, validates working-set safety margins to prevent instant OOM, blocks mutations when a resize is already in progress, and maintains identical limits and requests to protect the Guaranteed QoS class.
```typescript
import { V1Pod, V1Container } from '@kubernetes/client-node';

interface ResizeParams {
  cpu: string;
  memory: string;
  currentWorkingSetBytes: bigint;
  targetMemoryBytes: bigint;
}

// PRODUCTION-GRADE: Explicit resizePolicy, Guaranteed QoS preservation, and working set safety
export function buildInPlaceResizePatch(targetPod: V1Pod, params: ResizeParams) {
  const container = targetPod.spec?.containers[0];
  if (!container) {
    throw new Error('Target pod contains no valid container spec');
  }

  // Prevent OOMKill by disallowing memory downscales below current active working set
  const safetyHeadroomBytes = (params.currentWorkingSetBytes * 115n) / 100n;
  if (params.targetMemoryBytes < safetyHeadroomBytes) {
    throw new Error(
      `Cannot downscale memory to ${params.targetMemoryBytes} bytes; ` +
      `current working set is ${params.currentWorkingSetBytes} bytes (requires 15% headroom).`
    );
  }

  // Verify no in-flight resize operation is pending
  const resizeStatus = (targetPod.status as { resize?: string })?.resize;
  if (resizeStatus === 'InProgress') {
    throw new Error(`Pod ${targetPod.metadata?.name} already has an in-flight resize operation`);
  }

  return {
    apiVersion: 'v1',
    kind: 'Pod',
    metadata: {
      name: targetPod.metadata?.name,
      namespace: targetPod.metadata?.namespace,
    },
    spec: {
      containers: [
        {
          name: container.name,
          // Explicitly declare In-Place resize policies for K8s 1.32
          resizePolicy: [
            { resourceName: 'cpu', restartPolicy: 'NotRequired' },
            { resourceName: 'memory', restartPolicy: 'NotRequired' },
          ],
          resources: {
            limits: {
              cpu: params.cpu,
              memory: params.memory,
            },
            // Maintain Guaranteed QoS boundary (Limits === Requests)
            requests: {
              cpu: params.cpu,
              memory: params.memory,
            },
          },
        },
      ],
    },
  };
}
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Kubernetes 1.32 In-Place Dynamic Pod Resizing Resource Boundary Standard

Kubernetes 1.32 In-Place Dynamic Pod Resizing Resource Boundary Standard defines an industrial-grade behavioral standard for devops engineering. Enforces strict resource boundary invariants and explicit resize policies under Kubernetes 1.32 InPlacePodVerticalScaling. Prevents silent container restarts, eviction cascades, and QoS degradation during automated CPU and memory scaling events. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Patching Pod Container Resources Without Explicit Resize Policies or QoS Boundary Checks Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftPatching Pod Container Resources Without Explicit Resize Policies or QoS Boundary ChecksCritical
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST ALWAYS declare `resizePolicy` explicitly for both `cpu` and `memory` on all scalable container specifications.

Engineers MUST ALWAYS declare `resizePolicy` explicitly for both `cpu` and `memory` on all scalable container specifications.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST set `restartPolicy

Engineers MUST set `restartPolicy: NotRequired` for CPU and memory only when runtime images and runtimes (e.g., containerd 2.0+) support non-restart live resizing.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Engineers MUST NEVER decrease container memory limits below the current working set bytes reported by metrics/cgroups to avoid instantaneous SIGKILL (OOMKilled).

Engineers MUST NEVER decrease container memory limits below the current working set bytes reported by metrics/cgroups to avoid instantaneous SIGKILL (OOMKilled).

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Code MUST verify `pod.status.resize` is unset or `Infeasible`/`Proposed` has resolved before issuing a subsequent resource PATCH to avoid race conditions and stale allocation locks.

Code MUST verify `pod.status.resize` is unset or `Infeasible`/`Proposed` has resolved before issuing a subsequent resource PATCH to avoid race conditions and stale allocation locks.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Services MUST maintain parity between requests and limits when targeting the `Guaranteed` Quality of Service (QoS) tier

Services MUST maintain parity between requests and limits when targeting the `Guaranteed` Quality of Service (QoS) tier; resource patches must scale limits and requests synchronously.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
6

Controllers MUST execute patches against the `/resize` subresource or pod patch endpoint using Server-Side Apply (SSA) with managed field managers.

Controllers MUST execute patches against the `/resize` subresource or pod patch endpoint using Server-Side Apply (SSA) with managed field managers.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Kubernetes 1.32 In-Place Dynamic Pod Resizing Resource Boundary Standard critical for AI coding assistants?

Enforces strict resource boundary invariants and explicit resize policies under Kubernetes 1.32 InPlacePodVerticalScaling. Prevents silent container restarts, eviction cascades, and QoS degradation during automated CPU and memory scaling events. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (Patching Pod Container Resources Without Explicit Resize Policies or QoS Boundary Checks) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

1 Rule in Stack

Kubernetes