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

Kubernetes 1.32 Dynamic Resource Allocation (DRA) Structured CDI Device Claim Invariant

Enforces Kubernetes 1.32 Dynamic Resource Allocation (DRA) structured parameters and Container Device Interface (CDI) contracts over legacy opaque integer device requests. Eliminates cross-socket NUMA penalties, PCIe root complex contention, and NVLink topology partitioning by mandating CEL-based DeviceClass selector claims for all accelerator-bound inference pods.

Prohibited Anti-Pattern: Assigning AI workloads via opaque integer device limits ('nvidia.com/gpu') without topology-aware DRA resource claims.

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Kubernetes 1.32 Dynamic Resource Allocation (DRA) Structured CDI Device Claim Invariant - Enforces Kubernetes 1.32 Dynamic Resource Allocation (DRA) structured parameters and Container Device Interface (CDI) contracts over legacy opaque integer device requests. Eliminates cross-socket NUMA penalties, PCIe root complex contention, and NVLink topology partitioning by mandating CEL-based DeviceClass selector claims for all accelerator-bound inference pods.
globs: deployments/**/*.yaml, k8s/**/*.yaml, helm/**/*.yaml, src/infrastructure/**/*.ts, cdk8s/**/*.ts
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/k8s-132-dra-cdi-device-claim-invariant"
---

# Kubernetes 1.32 Dynamic Resource Allocation (DRA) Structured CDI Device Claim Invariant

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Assigning AI workloads via opaque integer device limits ('nvidia.com/gpu') without topology-aware DRA resource claims.

## System Constraints
You are a Principal Cloud Native Systems Architect specializing in Kubernetes 1.32 scheduling internals, Dynamic Resource Allocation (DRA), and low-latency AI inference workloads. Your objective is to enforce the Dynamic Resource Allocation CDI Device Claim Invariant across all infrastructure manifests, CDK8s constructs, and operator code.

Reject any pull request or deployment manifest that allocates accelerators (GPUs, TPUs, LPUs) via legacy opaque integer counters (e.g., `resources.limits: nvidia.com/gpu: N`). Such legacy allocations lack PCIe and NVLink bus-level topology awareness, resulting in asymmetric bus latency, cross-NUMA interconnect saturation, and compute underutilization during multi-tenant tensor parallel inference.

Mandate strict adherence to Kubernetes 1.32 `resource.k8s.io/v1beta1` DRA structured parameters. Every accelerator allocation must execute through a `ResourceClaim` or `resourceClaimTemplate` referencing validated `DeviceClass` objects with Common Expression Language (CEL) predicates ensuring strict interconnect topology, direct peer-to-peer NVLink mesh binding, and CDI-managed isolation.

## Strict Guidelines
- Engineers MUST ALWAYS declare accelerator requirements using `resource.k8s.io/v1beta1` `ResourceClaim` or inline `resourceClaimTemplates` instead of `resources.requests` or `resources.limits` device strings.
- Engineers MUST NOT reference vendor-specific opaque integer resources (e.g., `nvidia.com/gpu`, `amd.com/gpu`, `habana.ai/gaudi`) in container resource budgets for inference clusters.
- Code SHOULD bind accelerator claims to a `DeviceClass` configured with CEL selector expressions matching interconnect bandwidth, NUMA alignment, and NVLink mesh integrity.
- Services MUST declare structured CDI device configurations (`requests[].device.selectors`) ensuring dedicated hardware bus arbitration and preventing fractional memory/cache spillover.
- Pod templates NEVER combine legacy device plugins with DRA resource claims on the same accelerator devices or NUMA domains.

## Bad vs Good Implementations
### Constructing K8s Pod Device Allocation with CDK8s / TypeScript SDK

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Legacy opaque integer limits (`nvidia.com/gpu: '2'`) assign arbitrary hardware devices. The scheduler cannot evaluate if the two allocated accelerators share a high-bandwidth NVLink bridge or are stranded across opposing NUMA nodes and PCIe root complexes, degrading throughput by up to 40% during tensor parallel execution.
```typescript
// INCORRECT: Legacy opaque integer resource allocation
// Violates DRA invariant, ignores NVLink mesh topology and NUMA alignment
import { ApiObject } from 'cdk8s';
import { Construct } from 'constructs';

export class InferenceDeploymentBad extends Construct {
  constructor(scope: Construct, id: string) {
    super(scope, id);

    new ApiObject(this, 'InferencePod', {
      apiVersion: 'v1',
      kind: 'Pod',
      metadata: { name: 'llm-inference-v1' },
      spec: {
        containers: [
          {
            name: 'vllm-engine',
            image: 'vllm/vllm-openai:v0.6.0',
            resources: {
              limits: {
                cpu: '16',
                memory: '64Gi',
                'nvidia.com/gpu': '2', // Flaw: Blind integer allocation causes cross-PCIe bus contention
              },
            },
          },
        ],
      },
    });
  }
}
```

#### Production Standard (Correct)
> **Standard**: Uses Kubernetes 1.32 Dynamic Resource Allocation (`resource.k8s.io/v1beta1`) with a `ResourceClaimTemplate`. Structured parameters evaluate CEL expressions guaranteeing that both requested GPUs share a direct NVLink interconnect and are bound to NUMA node 0, eliminating hardware bus contention and maximizing tensor-parallel execution speed.
```typescript
// CORRECT: Kubernetes 1.32 DRA structured parameters with CDI
// Guarantees NVLink mesh topology and NUMA node alignment via ResourceClaimTemplate
import { ApiObject } from 'cdk8s';
import { Construct } from 'constructs';

export class InferenceDeploymentGood extends Construct {
  constructor(scope: Construct, id: string) {
    super(scope, id);

    new ApiObject(this, 'InferencePod', {
      apiVersion: 'v1',
      kind: 'Pod',
      metadata: { name: 'llm-inference-v1' },
      spec: {
        resourceClaims: [
          {
            name: 'accelerator-mesh',
            resourceClaimTemplateName: 'nvlink-paired-h100-template',
          },
        ],
        containers: [
          {
            name: 'vllm-engine',
            image: 'vllm/vllm-openai:v0.6.0',
            resources: {
              claims: [
                { name: 'accelerator-mesh' },
              ],
              limits: {
                cpu: '16',
                memory: '64Gi',
              },
            },
          },
        ],
      },
    });

    new ApiObject(this, 'ClaimTemplate', {
      apiVersion: 'resource.k8s.io/v1beta1',
      kind: 'ResourceClaimTemplate',
      metadata: { name: 'nvlink-paired-h100-template' },
      spec: {
        spec: {
          devices: {
            requests: [
              {
                name: 'h100-pair',
                deviceClassName: 'gpu.nvidia.com',
                count: 2,
                selectors: [
                  {
                    cel: {
                      expression: "device.attributes['gpu.nvidia.com'].nvlink_peers.size() >= 1 && device.attributes['gpu.nvidia.com'].numa_node == 0",
                    },
                  },
                ],
              },
            ],
          },
        },
      },
    });
  }
}
```

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 Dynamic Resource Allocation (DRA) Structured CDI Device Claim Invariant

Kubernetes 1.32 Dynamic Resource Allocation (DRA) Structured CDI Device Claim Invariant defines an industrial-grade behavioral standard for devops engineering. Enforces Kubernetes 1.32 Dynamic Resource Allocation (DRA) structured parameters and Container Device Interface (CDI) contracts over legacy opaque integer device requests. Eliminates cross-socket NUMA penalties, PCIe root complex contention, and NVLink topology partitioning by mandating CEL-based DeviceClass selector claims for all accelerator-bound inference pods. 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: Assigning AI workloads via opaque integer device limits ('nvidia.com/gpu') without topology-aware DRA resource claims. 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 DriftAssigning AI workloads via opaque integer device limits ('nvidia.com/gpu') without topology-aware DRA resource claims.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 declare accelerator requirements using `resource.k8s.io/v1beta1` `ResourceClaim` or inline `resourceClaimTemplates` instead of `resources.requests` or `resources.limits` device strings.

Engineers MUST ALWAYS declare accelerator requirements using `resource.k8s.io/v1beta1` `ResourceClaim` or inline `resourceClaimTemplates` instead of `resources.requests` or `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 reference vendor-specific opaque integer resources (e.g., `nvidia.com/gpu`, `amd.com/gpu`, `habana.ai/gaudi`) in container resource budgets for inference clusters.

Engineers MUST NOT reference vendor-specific opaque integer resources (e.g., `nvidia.com/gpu`, `amd.com/gpu`, `habana.ai/gaudi`) in container resource budgets for inference clusters.

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

Code SHOULD bind accelerator claims to a `DeviceClass` configured with CEL selector expressions matching interconnect bandwidth, NUMA alignment, and NVLink mesh integrity.

Code SHOULD bind accelerator claims to a `DeviceClass` configured with CEL selector expressions matching interconnect bandwidth, NUMA alignment, and NVLink mesh integrity.

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 MUST declare structured CDI device configurations (`requests[].device.selectors`) ensuring dedicated hardware bus arbitration and preventing fractional memory/cache spillover.

Services MUST declare structured CDI device configurations (`requests[].device.selectors`) ensuring dedicated hardware bus arbitration and preventing fractional memory/cache spillover.

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

Pod templates NEVER combine legacy device plugins with DRA resource claims on the same accelerator devices or NUMA domains.

Pod templates NEVER combine legacy device plugins with DRA resource claims on the same accelerator devices or NUMA domains.

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 Dynamic Resource Allocation (DRA) Structured CDI Device Claim Invariant critical for AI coding assistants?

Enforces Kubernetes 1.32 Dynamic Resource Allocation (DRA) structured parameters and Container Device Interface (CDI) contracts over legacy opaque integer device requests. Eliminates cross-socket NUMA penalties, PCIe root complex contention, and NVLink topology partitioning by mandating CEL-based DeviceClass selector claims for all accelerator-bound inference pods. 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 (Assigning AI workloads via opaque integer device limits ('nvidia.com/gpu') without topology-aware DRA resource claims.) 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