This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: k8s-132-in-place-vpa-memory-invariant

Kubernetes 1.32 In-Place Pod Resource Resizing and cgroup v2 Memory Invariant

Enforces deterministic specification of container `resizePolicy` for CPU and memory in Kubernetes 1.32+ workloads. Prevents abrupt pod restarts and cgroup v2 kernel Out-Of-Memory (OOM) kills triggered when memory limits are dynamically scaled down below current container working set sizes (`memory.current`). Ensures declarative alignment between Pod resources, container runtime limits, and Vertical Pod Autoscaler (VPA) in-place update configurations.

Prohibited Anti-Pattern: Omitting explicit resizePolicy or dynamically lowering memory limits below working set size without restart safety gates, triggering instantaneous cgroup v2 OOM invocation.

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Kubernetes 1.32 In-Place Pod Resource Resizing and cgroup v2 Memory Invariant - Enforces deterministic specification of container `resizePolicy` for CPU and memory in Kubernetes 1.32+ workloads. Prevents abrupt pod restarts and cgroup v2 kernel Out-Of-Memory (OOM) kills triggered when memory limits are dynamically scaled down below current container working set sizes (`memory.current`). Ensures declarative alignment between Pod resources, container runtime limits, and Vertical Pod Autoscaler (VPA) in-place update configurations.
globs: **/*.yaml, **/*.yml, deploy/kubernetes/**/*.yaml, helm/**/templates/*.yaml, charts/**/templates/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/k8s-132-in-place-vpa-memory-invariant"
---

# Kubernetes 1.32 In-Place Pod Resource Resizing and cgroup v2 Memory Invariant

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Omitting explicit resizePolicy or dynamically lowering memory limits below working set size without restart safety gates, triggering instantaneous cgroup v2 OOM invocation.

## System Constraints
You are a Principal Cloud Native Systems Architect enforcing the Kubernetes 1.32 In-Place Pod Vertical Scaling (KEP-1287) standard. You must ensure all stateful and mission-critical container specs explicitly define `resizePolicy` for both `cpu` and `memory`. You must prevent runtime pod evictions and ensure memory downscaling is constrained by cgroup v2 memory invariants so that container memory limits are never reduced below live heap or active working sets without controlled pod restarts.

## Strict Guidelines
- Engineers MUST ALWAYS define `spec.containers[*].resizePolicy` when configuring workloads intended for non-disruptive vertical scaling.
- Engineers MUST set `restartPolicy: NotRequired` for `cpu` on compute-bound workloads, but MUST evaluate application runtime memory elasticity before setting `restartPolicy: NotRequired` on `memory`.
- Engineers MUST NOT allow in-place memory downscaling (`resizePolicy: [resourceName: memory, restartPolicy: NotRequired]`) for runtimes that cannot dynamically release committed virtual memory back to the OS (e.g., default JVM, Erlang BEAM, Go standard runtime without `GODEBUG=madvdontneed=1`).
- Services using Vertical Pod Autoscaler (VPA) with `updateMode: InPlaceOnly` or `updateMode: Auto` MUST specify `minAllowed` memory limits higher than the application's irreducible runtime baseline to prevent cgroup v2 immediate SIGKILL.
- Components NEVER specify unbounded memory limits (`limits.memory` omitted while `requests.memory` is set) when using in-place resizing, as transitions from unconstrained to constrained memory cgroups induce instantaneous memory pressure stalls.
- Workloads MUST configure readiness and liveness probes that observe `PodStatus.AllocatedResources` vs `PodStatus.Resize` status fields during pending in-place scaling events.

## Bad vs Good Implementations
### Kubernetes 1.32 Stateful Deployment with In-Place Resize Policy & VPA Bounds

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Fails to declare `resizePolicy`. When VPA applies resource changes, Kubernetes default behaviors may restart the container. Furthermore, if memory is resized downwards in place while the application maintains active working set allocations, cgroup v2 `memory.max` drops below `memory.current`, invoking the Linux kernel OOM killer instantly.
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: order-processor
spec:
  replicas: 3
  template:
    spec:
      containers:
        - name: processor
          image: payment/processor:v2.4.0
          resources:
            requests:
              cpu: "1000m"
              memory: "2Gi"
            limits:
              cpu: "2000m"
              memory: "4Gi"
          # ANTI-PATTERN: Omitted resizePolicy defaults or leads to
          # full pod restarts during dynamic scaling in K8s 1.32+.
          # VPA downscaling limits below current heap immediately triggers
          # cgroup v2 OOM kill (exit code 137).
```

#### Production Standard (Correct)
> **Standard**: Explicitly declares `resizePolicy` separating CPU (non-disruptive, `NotRequired`) from Memory (`RestartContainer` or safely bound), preventing cgroup v2 OOM kills. Accompanied by a VPA configuration with `minAllowed` bounds ensuring memory limits never drop below the operational working set floor.
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: order-processor
spec:
  replicas: 3
  template:
    spec:
      containers:
        - name: processor
          image: payment/processor:v2.4.0
          # INVARIANT: Explicit resizePolicy defined for K8s 1.32 in-place scaling
          resizePolicy:
            - resourceName: cpu
              restartPolicy: NotRequired
            - resourceName: memory
              restartPolicy: RestartContainer
          resources:
            requests:
              cpu: "1000m"
              memory: "2Gi"
            limits:
              cpu: "2000m"
              memory: "4Gi"
---
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: order-processor-vpa
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: order-processor
  updatePolicy:
    updateMode: "InPlaceOnly"
  resourcePolicy:
    containerPolicies:
      - containerName: processor
        minAllowed:
          cpu: "500m"
          memory: "2Gi"
        maxAllowed:
          cpu: "4000m"
          memory: "8Gi"
        controlledResources: ["cpu", "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 Pod Resource Resizing and cgroup v2 Memory Invariant

Kubernetes 1.32 In-Place Pod Resource Resizing and cgroup v2 Memory Invariant defines an industrial-grade behavioral standard for devops engineering. Enforces deterministic specification of container `resizePolicy` for CPU and memory in Kubernetes 1.32+ workloads. Prevents abrupt pod restarts and cgroup v2 kernel Out-Of-Memory (OOM) kills triggered when memory limits are dynamically scaled down below current container working set sizes (`memory.current`). Ensures declarative alignment between Pod resources, container runtime limits, and Vertical Pod Autoscaler (VPA) in-place update configurations. 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: Omitting explicit resizePolicy or dynamically lowering memory limits below working set size without restart safety gates, triggering instantaneous cgroup v2 OOM invocation. 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 DriftOmitting explicit resizePolicy or dynamically lowering memory limits below working set size without restart safety gates, triggering instantaneous cgroup v2 OOM invocation.Critical
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 define `spec.containers[*].resizePolicy` when configuring workloads intended for non-disruptive vertical scaling.

Engineers MUST ALWAYS define `spec.containers[*].resizePolicy` when configuring workloads intended for non-disruptive vertical scaling.

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` on compute-bound workloads, but MUST evaluate application runtime memory elasticity before setting `restartPolicy: NotRequired` on `memory`.

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 NOT allow in-place memory downscaling (`resizePolicy

Engineers MUST NOT allow in-place memory downscaling (`resizePolicy: [resourceName: memory, restartPolicy: NotRequired]`) for runtimes that cannot dynamically release committed virtual memory back to the OS (e.g., default JVM, Erlang BEAM, Go standard runtime without `GODEBUG=madvdontneed=1`).

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

Services using Vertical Pod Autoscaler (VPA) with `updateMode

Services using Vertical Pod Autoscaler (VPA) with `updateMode: InPlaceOnly` or `updateMode: Auto` MUST specify `minAllowed` memory limits higher than the application's irreducible runtime baseline to prevent cgroup v2 immediate SIGKILL.

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

Components NEVER specify unbounded memory limits (`limits.memory` omitted while `requests.memory` is set) when using in-place resizing, as transitions from unconstrained to constrained memory cgroups induce instantaneous memory pressure stalls.

Components NEVER specify unbounded memory limits (`limits.memory` omitted while `requests.memory` is set) when using in-place resizing, as transitions from unconstrained to constrained memory cgroups induce instantaneous memory pressure stalls.

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

Workloads MUST configure readiness and liveness probes that observe `PodStatus.AllocatedResources` vs `PodStatus.Resize` status fields during pending in-place scaling events.

Workloads MUST configure readiness and liveness probes that observe `PodStatus.AllocatedResources` vs `PodStatus.Resize` status fields during pending in-place scaling events.

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 Pod Resource Resizing and cgroup v2 Memory Invariant critical for AI coding assistants?

Enforces deterministic specification of container `resizePolicy` for CPU and memory in Kubernetes 1.32+ workloads. Prevents abrupt pod restarts and cgroup v2 kernel Out-Of-Memory (OOM) kills triggered when memory limits are dynamically scaled down below current container working set sizes (`memory.current`). Ensures declarative alignment between Pod resources, container runtime limits, and Vertical Pod Autoscaler (VPA) in-place update configurations. 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 (Omitting explicit resizePolicy or dynamically lowering memory limits below working set size without restart safety gates, triggering instantaneous cgroup v2 OOM invocation.) 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