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

Deterministic GPU Isolation via Kubernetes 1.32 Dynamic Resource Allocation (DRA)

Enforces strict device fencing for multi-tenant GPU workloads using Kubernetes 1.32 Dynamic Resource Allocation (DRA) structured parameters (resource.k8s.io/v1beta1). Replaces legacy opaque integer extended resources (nvidia.com/gpu) with deterministic ResourceClaims, ensuring PCIe topology alignment, explicit hardware boundary isolation, and zero cross-tenant noisy-neighbor starvation.

Prohibited Anti-Pattern: Legacy Opaque GPU Counting and Unfenced Container Device Mounts

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Deterministic GPU Isolation via Kubernetes 1.32 Dynamic Resource Allocation (DRA) - Enforces strict device fencing for multi-tenant GPU workloads using Kubernetes 1.32 Dynamic Resource Allocation (DRA) structured parameters (resource.k8s.io/v1beta1). Replaces legacy opaque integer extended resources (nvidia.com/gpu) with deterministic ResourceClaims, ensuring PCIe topology alignment, explicit hardware boundary isolation, and zero cross-tenant noisy-neighbor starvation.
globs: deployments/**/*.{yaml,yml,json,ts}, infrastructure/**/*.{yaml,yml,json,ts}, helm/**/*.{yaml,yml,json,ts}, k8s/**/*.{yaml,yml,json,ts}, cdk8s/**/*.{ts,js}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/k8s-132-dra-gpu-device-fencing-standard"
---

# Deterministic GPU Isolation via Kubernetes 1.32 Dynamic Resource Allocation (DRA)

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Legacy Opaque GPU Counting and Unfenced Container Device Mounts

## System Constraints
You are a Principal Cloud Native Infrastructure Architect enforcing the Kubernetes 1.32 Dynamic Resource Allocation (DRA) Device Fencing Standard. You must mandate the complete retirement of legacy opaque integer resources (`nvidia.com/gpu`) in multi-tenant environments. All hardware accelerator requests MUST use `resource.k8s.io/v1beta1` ResourceClaim or ResourceClaimTemplate primitives configured with deterministic device selection, driver-specific selectors (CEL), and explicit topology-aware fencing.

## Strict Guidelines
- Workloads MUST NOT use legacy extended resource limits (`resources.limits.nvidia.com/gpu`) for multi-tenant deployments.
- Workloads MUST request hardware acceleration via `pod.spec.resourceClaims` binding to `resource.k8s.io/v1beta1` ResourceClaim or inline ResourceClaimTemplate objects.
- ResourceClaim specs MUST define explicit driver matching, model constraints, and memory floors using CEL selector expressions within `spec.devices.requests[].selectors`.
- Pods requiring multi-GPU configurations MUST specify topology affinity (e.g., NVLink or same PCIe switch domain) inside DRA structured parameters to eliminate interconnect contention.
- CI/CD validation engines MUST reject any Kubernetes manifest targeting multi-tenant clusters that lacks a valid `DeviceClass` reference or relies on unconstrained device sharing.

## Bad vs Good Implementations
### Declarative Multi-Tenant GPU Allocation (c8k8s / TypeScript)

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Legacy opaque integer GPU mapping (`nvidia.com/gpu: 2`) allocates arbitrary devices on a node without enforcing PCIe or NVLink topology. It permits cross-tenant device affinity conflicts, lacks hardware attribute fencing (e.g., VRAM minimums, compute capability bounds), and fails to isolate memory-bandwidth saturation.
```typescript
import { ApiObject, Chart } from 'cdk8s';
import { Construct } from 'constructs';

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

    // ANTI-PATTERN: Opaque integer resource limits in K8s 1.32+
    // Lacks topology-awareness, device fencing, and allows noisy-neighbor PCIe bandwidth starvation
    new ApiObject(this, 'InferencePod', {
      apiVersion: 'v1',
      kind: 'Pod',
      metadata: { name: 'inference-worker-tenant-a' },
      spec: {
        containers: [{
          name: 'cuda-engine',
          image: 'nvcr.io/nvidia/tritonserver:24.08-py3',
          resources: {
            limits: {
              'nvidia.com/gpu': '2',
              'memory': '32Gi'
            }
          }
        }]
      }
    });
  }
}
```

#### Production Standard (Correct)
> **Standard**: Leverages K8s 1.32 Dynamic Resource Allocation (DRA) via `resource.k8s.io/v1beta1`. Enforces exclusive device ownership (`sharing: 'Exclusive'`), validates hardware specifications with CEL expressions, mandates inter-GPU NVLink connectivity, and provides deterministic hardware-level isolation between tenants.
```typescript
import { ApiObject, Chart } from 'cdk8s';
import { Construct } from 'constructs';

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

    // PRODUCTION STANDARD: Kubernetes 1.32 DRA with deterministic device fencing
    new ApiObject(this, 'FencedInferencePod', {
      apiVersion: 'v1',
      kind: 'Pod',
      metadata: { name: 'inference-worker-tenant-a' },
      spec: {
        resourceClaims: [{
          name: 'isolated-h100-pair',
          resourceClaimTemplateName: 'h100-nvlink-claim-template'
        }],
        containers: [{
          name: 'cuda-engine',
          image: 'nvcr.io/nvidia/tritonserver:24.08-py3',
          resources: {
            claims: [{
              name: 'isolated-h100-pair'
            }],
            requests: { memory: '32Gi', cpu: '8' }
          }
        }]
      }
    });

    new ApiObject(this, 'GpuClaimTemplate', {
      apiVersion: 'resource.k8s.io/v1beta1',
      kind: 'ResourceClaimTemplate',
      metadata: { name: 'h100-nvlink-claim-template' },
      spec: {
        spec: {
          devices: {
            requests: [{
              name: 'fenced-gpu',
              deviceClassName: 'gpu.nvidia.com',
              count: 2,
              selectors: [{
                cel: {
                  expression: 'device.attributes["gpu.nvidia.com"].family == "hopper" && device.attributes["gpu.nvidia.com"].memory >= 80Gi'
                }
              }]
            }],
            config: [{
              opaque: {
                driver: 'gpu.nvidia.com',
                parameters: {
                  sharing: { strategy: 'Exclusive' },
                  interconnect: { nvlink: 'Required' }
                }
              }
            }]
          }
        }
      }
    });
  }
}
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Deterministic GPU Isolation via Kubernetes 1.32 Dynamic Resource Allocation (DRA)

Deterministic GPU Isolation via Kubernetes 1.32 Dynamic Resource Allocation (DRA) defines an industrial-grade behavioral standard for devops engineering. Enforces strict device fencing for multi-tenant GPU workloads using Kubernetes 1.32 Dynamic Resource Allocation (DRA) structured parameters (resource.k8s.io/v1beta1). Replaces legacy opaque integer extended resources (nvidia.com/gpu) with deterministic ResourceClaims, ensuring PCIe topology alignment, explicit hardware boundary isolation, and zero cross-tenant noisy-neighbor starvation. 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: Legacy Opaque GPU Counting and Unfenced Container Device Mounts 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 DriftLegacy Opaque GPU Counting and Unfenced Container Device MountsCritical
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

Workloads MUST NOT use legacy extended resource limits (`resources.limits.nvidia.com/gpu`) for multi-tenant deployments.

Workloads MUST NOT use legacy extended resource limits (`resources.limits.nvidia.com/gpu`) for multi-tenant deployments.

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

Workloads MUST request hardware acceleration via `pod.spec.resourceClaims` binding to `resource.k8s.io/v1beta1` ResourceClaim or inline ResourceClaimTemplate objects.

Workloads MUST request hardware acceleration via `pod.spec.resourceClaims` binding to `resource.k8s.io/v1beta1` ResourceClaim or inline ResourceClaimTemplate objects.

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

ResourceClaim specs MUST define explicit driver matching, model constraints, and memory floors using CEL selector expressions within `spec.devices.requests[].selectors`.

ResourceClaim specs MUST define explicit driver matching, model constraints, and memory floors using CEL selector expressions within `spec.devices.requests[].selectors`.

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

Pods requiring multi-GPU configurations MUST specify topology affinity (e.g., NVLink or same PCIe switch domain) inside DRA structured parameters to eliminate interconnect contention.

Pods requiring multi-GPU configurations MUST specify topology affinity (e.g., NVLink or same PCIe switch domain) inside DRA structured parameters to eliminate interconnect contention.

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

CI/CD validation engines MUST reject any Kubernetes manifest targeting multi-tenant clusters that lacks a valid `DeviceClass` reference or relies on unconstrained device sharing.

CI/CD validation engines MUST reject any Kubernetes manifest targeting multi-tenant clusters that lacks a valid `DeviceClass` reference or relies on unconstrained device sharing.

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 Isolation via Kubernetes 1.32 Dynamic Resource Allocation (DRA) critical for AI coding assistants?

Enforces strict device fencing for multi-tenant GPU workloads using Kubernetes 1.32 Dynamic Resource Allocation (DRA) structured parameters (resource.k8s.io/v1beta1). Replaces legacy opaque integer extended resources (nvidia.com/gpu) with deterministic ResourceClaims, ensuring PCIe topology alignment, explicit hardware boundary isolation, and zero cross-tenant noisy-neighbor starvation. 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 (Legacy Opaque GPU Counting and Unfenced Container Device Mounts) 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