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

Kubernetes Dynamic Resource Allocation (DRA) vGPU Structured Parameter Fence

Enforces vendor-agnostic fractional hardware acceleration partitioning via Kubernetes Dynamic Resource Allocation (DRA) structured parameters and ResourceClaimTemplates. Prevents multi-tenant GPU memory thrashing, unisolated VRAM leaks, and cold-start scheduling starvation by replacing opaque extended resources with deterministic Common Expression Language (CEL) device selectors and strict memory fencing.

Prohibited Anti-Pattern: Opaque Extended Resource Allocation without Hardware Partitioning and Memory Fences

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Kubernetes Dynamic Resource Allocation (DRA) vGPU Structured Parameter Fence - Enforces vendor-agnostic fractional hardware acceleration partitioning via Kubernetes Dynamic Resource Allocation (DRA) structured parameters and ResourceClaimTemplates. Prevents multi-tenant GPU memory thrashing, unisolated VRAM leaks, and cold-start scheduling starvation by replacing opaque extended resources with deterministic Common Expression Language (CEL) device selectors and strict memory fencing.
globs: deploy/**/*.{yaml,yml}, k8s/**/*.{yaml,yml}, charts/**/templates/**/*.{yaml,yml}, infra/**/*.{ts,tsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/k8s-dra-vgpu-structured-parameter-fence"
---

# Kubernetes Dynamic Resource Allocation (DRA) vGPU Structured Parameter Fence

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Opaque Extended Resource Allocation without Hardware Partitioning and Memory Fences

## System Constraints
You are a Principal Platform Engineer enforcing Kubernetes Dynamic Resource Allocation (DRA) vGPU Structured Parameter Fences. Mandate the use of structured parameters (resource.k8s.io/v1beta1) with strict Common Expression Language (CEL) device selectors and explicit hardware boundaries. Forbid legacy opaque extended resources (e.g., 'nvidia.com/gpu', 'amd.com/gpu') in multi-tenant inference workloads to eliminate noisy-neighbor memory saturation, unisolated CUDA allocations, and non-deterministic scheduling starvation.

## Strict Guidelines
- Engineers MUST ALWAYS declare fractional GPU demands via 'resource.k8s.io/v1beta1' ResourceClaim or ResourceClaimTemplate objects using structured parameters instead of opaque extended resources.
- Engineers MUST NOT bind inference workloads to integer-based monolithic GPU requests (e.g., 'nvidia.com/gpu: 1') when workload VRAM footprints permit fractional spatial/temporal sharing.
- Workloads SHOULD declare strict CEL selection filters in 'matchAttribute' ensuring minimum compute capability, isolated VRAM quantity, and dedicated hardware slice guarantees.
- Services MUST define 'spec.containers[*].resources.claims' mapping explicitly to pod-level resource claims, fencing memory allocation boundaries at the hardware layer.
- Components NEVER permit dynamic fallback to unmanaged host CUDA memory or un-partitioned shared device nodes in multi-tenant namespaces.

## Bad vs Good Implementations
### Configuring Pod Workloads with Structured Parameter Resource Claims vs Opaque Extended Limits

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using opaque extended resources ('nvidia.com/gpu') bypasses modern hardware-enforced memory fences. It exposes workloads to noisy-neighbor memory corruption, limits fractional utilization, and causes unpredictable scheduling delays for cold starts.
```typescript
import { V1Pod, V1Container } from '@kubernetes/client-node';

// ANTI-PATTERN: Using opaque extended resources without hardware fencing
export function createInferencePod(name: string, image: string): V1Pod {
  return {
    apiVersion: 'v1',
    kind: 'Pod',
    metadata: { name },
    spec: {
      containers: [{
        name: 'model-server',
        image,
        resources: {
          // Flaw: Requests full device or relies on unmanaged software time-slicing.
          // Causes noisy-neighbor VRAM out-of-memory errors and scheduling starvation.
          limits: { 'nvidia.com/gpu': '1' },
          requests: { 'nvidia.com/gpu': '1' }
        }
      }]
    }
  };
}
```

#### Production Standard (Correct)
> **Standard**: Adheres to Kubernetes DRA structured parameters. By specifying exact hardware profiles and isolated VRAM via CEL selectors, the scheduler binds deterministic fractional resources, mitigating memory exhaustion and noisy-neighbor latency spikes.
```typescript
import { V1Pod } from '@kubernetes/client-node';

// PRODUCTION INVARIANT: Kubernetes DRA Structured Parameters with CEL Isolation
export function createInferencePod(name: string, image: string): V1Pod {
  return {
    apiVersion: 'v1',
    kind: 'Pod',
    metadata: { name },
    spec: {
      resourceClaims: [{
        name: 'vgpu-claim',
        resourceClaimTemplateName: `${name}-vgpu-template`
      }],
      containers: [{
        name: 'model-server',
        image,
        resources: {
          claims: [{ name: 'vgpu-claim' }],
          limits: { cpu: '4', memory: '16Gi' },
          requests: { cpu: '2', memory: '8Gi' }
        }
      }]
    }
  };
}

// Accompanying ResourceClaimTemplate enforcing hardware-level vGPU fencing
export const vGpuResourceClaimTemplate = {
  apiVersion: 'resource.k8s.io/v1beta1',
  kind: 'ResourceClaimTemplate',
  metadata: { name: 'inference-vgpu-template' },
  spec: {
    spec: {
      devices: {
        requests: [{
          name: 'isolated-vgpu',
          deviceClassName: 'gpu.workload.io',
          selectors: [{
            cel: {
              expression: "device.attributes['gpu.vendor.io/memory'].quantity >= quantity('16Gi') && device.attributes['gpu.vendor.io/compute-profile'] == '2g.16gb'"
            }
          }]
        }]
      }
    }
  }
};
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Kubernetes Dynamic Resource Allocation (DRA) vGPU Structured Parameter Fence

Kubernetes Dynamic Resource Allocation (DRA) vGPU Structured Parameter Fence defines an industrial-grade behavioral standard for devops engineering. Enforces vendor-agnostic fractional hardware acceleration partitioning via Kubernetes Dynamic Resource Allocation (DRA) structured parameters and ResourceClaimTemplates. Prevents multi-tenant GPU memory thrashing, unisolated VRAM leaks, and cold-start scheduling starvation by replacing opaque extended resources with deterministic Common Expression Language (CEL) device selectors and strict memory fencing. 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: Opaque Extended Resource Allocation without Hardware Partitioning and Memory Fences 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 DriftOpaque Extended Resource Allocation without Hardware Partitioning and Memory FencesCritical
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 fractional GPU demands via 'resource.k8s.io/v1beta1' ResourceClaim or ResourceClaimTemplate objects using structured parameters instead of opaque extended resources.

Engineers MUST ALWAYS declare fractional GPU demands via 'resource.k8s.io/v1beta1' ResourceClaim or ResourceClaimTemplate objects using structured parameters instead of opaque extended resources.

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 bind inference workloads to integer-based monolithic GPU requests (e.g., 'nvidia.com/gpu

Engineers MUST NOT bind inference workloads to integer-based monolithic GPU requests (e.g., 'nvidia.com/gpu: 1') when workload VRAM footprints permit fractional spatial/temporal 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.
3

Workloads SHOULD declare strict CEL selection filters in 'matchAttribute' ensuring minimum compute capability, isolated VRAM quantity, and dedicated hardware slice guarantees.

Workloads SHOULD declare strict CEL selection filters in 'matchAttribute' ensuring minimum compute capability, isolated VRAM quantity, and dedicated hardware slice guarantees.

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 define 'spec.containers[*].resources.claims' mapping explicitly to pod-level resource claims, fencing memory allocation boundaries at the hardware layer.

Services MUST define 'spec.containers[*].resources.claims' mapping explicitly to pod-level resource claims, fencing memory allocation boundaries at the hardware layer.

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 permit dynamic fallback to unmanaged host CUDA memory or un-partitioned shared device nodes in multi-tenant namespaces.

Components NEVER permit dynamic fallback to unmanaged host CUDA memory or un-partitioned shared device nodes in multi-tenant namespaces.

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 Dynamic Resource Allocation (DRA) vGPU Structured Parameter Fence critical for AI coding assistants?

Enforces vendor-agnostic fractional hardware acceleration partitioning via Kubernetes Dynamic Resource Allocation (DRA) structured parameters and ResourceClaimTemplates. Prevents multi-tenant GPU memory thrashing, unisolated VRAM leaks, and cold-start scheduling starvation by replacing opaque extended resources with deterministic Common Expression Language (CEL) device selectors and strict memory fencing. 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 (Opaque Extended Resource Allocation without Hardware Partitioning and Memory Fences) 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