This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: k8s-dra-gpu-partitioning-fence-standard

Deterministic GPU Partitioning with Kubernetes 1.32 Dynamic Resource Allocation (DRA)

Enforces Kubernetes 1.32 Structured Resource Claims via resource.k8s.io/v1beta1 for multi-tenant accelerator workloads, completely replacing legacy static device-plugin limit injections. Guarantees deterministic hardware slicing (MIG/vGPU/MPS) with strict memory and compute isolation fences at the kube-scheduler level. Eliminates cross-tenant memory starvation and non-deterministic scheduler preemption failures during co-located inference.

Prohibited Anti-Pattern: Binding Multi-Tenant Workloads to Static nvidia.com/gpu Limits with Unenforced Host-Level MIG/MPS Slicing

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Deterministic GPU Partitioning with Kubernetes 1.32 Dynamic Resource Allocation (DRA) - Enforces Kubernetes 1.32 Structured Resource Claims via resource.k8s.io/v1beta1 for multi-tenant accelerator workloads, completely replacing legacy static device-plugin limit injections. Guarantees deterministic hardware slicing (MIG/vGPU/MPS) with strict memory and compute isolation fences at the kube-scheduler level. Eliminates cross-tenant memory starvation and non-deterministic scheduler preemption failures during co-located inference.
globs: deploy/**/*.{yaml,yml}, k8s/**/*.{yaml,yml}, helm/**/*.{yaml,yml}, manifests/**/*.{yaml,yml}, infra/**/*.{yaml,yml}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/k8s-dra-gpu-partitioning-fence-standard"
---

# Deterministic GPU Partitioning with Kubernetes 1.32 Dynamic Resource Allocation (DRA)

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Binding Multi-Tenant Workloads to Static nvidia.com/gpu Limits with Unenforced Host-Level MIG/MPS Slicing

## System Constraints
You are a Principal Infrastructure Architect enforcing Kubernetes 1.32 Dynamic Resource Allocation (DRA) GPU Partitioning Fences. Mandate the use of structured parameters (resource.k8s.io/v1beta1) instead of legacy static container device plugin declarations (e.g., nvidia.com/gpu, nvidia.com/mig-*). Reject any configuration attempting to partition GPUs using unmanaged environment variables (NVIDIA_VISIBLE_DEVICES), host-level MPS daemons without scheduler-aware claim templates, or fractional static limits. Ensure all claims specify exact DeviceClass definitions, preemption-safe isolation semantics, and explicit resource claim life-cycles.

## Strict Guidelines
- Engineers MUST ALWAYS declare accelerator requirements using `resource.k8s.io/v1beta1` ResourceClaim or ResourceClaimTemplate manifests instead of `resources.limits` device strings.
- Engineers MUST NOT configure static extended resource limits like `nvidia.com/gpu` or vendor-specific legacy MIG labels (`nvidia.com/mig-3g.40gb`) for partitioned multi-tenant inference workloads.
- Pods requiring partitioned GPU access MUST bind claims using container-level `resources.claims` referencing a valid Pod-level `resourceClaims` entry.
- Infrastructure declarations MUST specify an authoritative `deviceClassName` configured for structured parameters and deterministic hardware fences (e.g., MIG geometry, memory boundaries).
- Services MUST NEVER rely on runtime environment variables (`NVIDIA_VISIBLE_DEVICES`, `CUDA_VISIBLE_DEVICES`) to artificially partition physical devices across tenant boundaries.

## Bad vs Good Implementations
### Legacy Device Plugin Limit vs Kubernetes 1.32 DRA Structured Resource Claim

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Legacy static limits consume entire physical devices or rely on error-prone env-var partitioning. The kube-scheduler has no visibility into internal MIG slices or memory ceilings, causing resource fragmentation, noisy-neighbor contention, and silent OOM evictions under multi-tenant load.
```yaml
# INSECURE & FRAGILE: Legacy static limits with unmanaged environment variable slicing
apiVersion: apps/v1
kind: Deployment
metadata:
  name: llm-inference-tenant-a
spec:
  replicas: 2
  template:
    spec:
      containers:
        - name: inference-engine
          image: vllm/vllm-openai:v0.6.0
          env:
            - name: NVIDIA_VISIBLE_DEVICES
              value: "0:0" # Manual MIG slice bypassing scheduler validation
          resources:
            limits:
              nvidia.com/gpu: "1" # Consumes whole physical GPU despite slicing intent
            requests:
              cpu: "4"
              memory: "16Gi"
```

#### Production Standard (Correct)
> **Standard**: Leverages Kubernetes 1.32 DRA structured parameters. The kube-scheduler directly matches device attributes via CEL expressions, enforcing hardware-level MIG isolation and preemption fences natively without manual environment overrides or node-level configuration drift.
```yaml
# RESILIENT: Kubernetes 1.32 Dynamic Resource Allocation (DRA) with Structured Resource Claims
apiVersion: resource.k8s.io/v1beta1
kind: ResourceClaimTemplate
metadata:
  name: gpu-partition-3g40gb
spec:
  spec:
    devices:
      requests:
        - name: dedicated-mig-slice
          deviceClassName: gpu.nvidia.com
          selectors:
            - cel:
                expression: "device.attributes['gpu.nvidia.com'].migProfile == '3g.40gb' && device.attributes['gpu.nvidia.com'].memory >= 40Gi"
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: llm-inference-tenant-a
spec:
  replicas: 2
  template:
    spec:
      resourceClaims:
        - name: gpu-claim
          resourceClaimTemplateName: gpu-partition-3g40gb
      containers:
        - name: inference-engine
          image: vllm/vllm-openai:v0.6.0
          resources:
            claims:
              - name: gpu-claim
            limits:
              memory: "32Gi"
            requests:
              cpu: "4"
              memory: "16Gi"
```

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: Deterministic GPU Partitioning with Kubernetes 1.32 Dynamic Resource Allocation (DRA)

Deterministic GPU Partitioning with Kubernetes 1.32 Dynamic Resource Allocation (DRA) defines an industrial-grade behavioral standard for devops engineering. Enforces Kubernetes 1.32 Structured Resource Claims via resource.k8s.io/v1beta1 for multi-tenant accelerator workloads, completely replacing legacy static device-plugin limit injections. Guarantees deterministic hardware slicing (MIG/vGPU/MPS) with strict memory and compute isolation fences at the kube-scheduler level. Eliminates cross-tenant memory starvation and non-deterministic scheduler preemption failures during co-located inference. 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: Binding Multi-Tenant Workloads to Static nvidia.com/gpu Limits with Unenforced Host-Level MIG/MPS Slicing 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 DriftBinding Multi-Tenant Workloads to Static nvidia.com/gpu Limits with Unenforced Host-Level MIG/MPS SlicingCritical
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 accelerator requirements using `resource.k8s.io/v1beta1` ResourceClaim or ResourceClaimTemplate manifests instead of `resources.limits` device strings.

Engineers MUST ALWAYS declare accelerator requirements using `resource.k8s.io/v1beta1` ResourceClaim or ResourceClaimTemplate manifests instead of `resources.limits` device strings.

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 NOT configure static extended resource limits like `nvidia.com/gpu` or vendor-specific legacy MIG labels (`nvidia.com/mig-3g.40gb`) for partitioned multi-tenant inference workloads.

Engineers MUST NOT configure static extended resource limits like `nvidia.com/gpu` or vendor-specific legacy MIG labels (`nvidia.com/mig-3g.40gb`) for partitioned multi-tenant inference workloads.

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

Pods requiring partitioned GPU access MUST bind claims using container-level `resources.claims` referencing a valid Pod-level `resourceClaims` entry.

Pods requiring partitioned GPU access MUST bind claims using container-level `resources.claims` referencing a valid Pod-level `resourceClaims` entry.

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

Infrastructure declarations MUST specify an authoritative `deviceClassName` configured for structured parameters and deterministic hardware fences (e.g., MIG geometry, memory boundaries).

Infrastructure declarations MUST specify an authoritative `deviceClassName` configured for structured parameters and deterministic hardware fences (e.g., MIG geometry, memory boundaries).

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 NEVER rely on runtime environment variables (`NVIDIA_VISIBLE_DEVICES`, `CUDA_VISIBLE_DEVICES`) to artificially partition physical devices across tenant boundaries.

Services MUST NEVER rely on runtime environment variables (`NVIDIA_VISIBLE_DEVICES`, `CUDA_VISIBLE_DEVICES`) to artificially partition physical devices across tenant boundaries.

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 Deterministic GPU Partitioning with Kubernetes 1.32 Dynamic Resource Allocation (DRA) critical for AI coding assistants?

Enforces Kubernetes 1.32 Structured Resource Claims via resource.k8s.io/v1beta1 for multi-tenant accelerator workloads, completely replacing legacy static device-plugin limit injections. Guarantees deterministic hardware slicing (MIG/vGPU/MPS) with strict memory and compute isolation fences at the kube-scheduler level. Eliminates cross-tenant memory starvation and non-deterministic scheduler preemption failures during co-located inference. 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 (Binding Multi-Tenant Workloads to Static nvidia.com/gpu Limits with Unenforced Host-Level MIG/MPS Slicing) 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

Deterministic