This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: karpenter-v1-topology-spread-consolidation-invariant

Karpenter v1.0 Quorum-Aware Topology Spread and Consolidation Guardrails

Enforces deterministic, multi-availability-zone resilience during autonomous Karpenter v1.0 Spot instance consolidation. Prevents simultaneous cross-AZ pod evictions by binding Karpenter disruption budgets with Kubernetes topologySpreadConstraints and strict PodDisruptionBudgets.

Prohibited Anti-Pattern: Unbounded NodePool Consolidation Draining Cross-AZ Workloads Concurrently During Spot Reclamation

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Karpenter v1.0 Quorum-Aware Topology Spread and Consolidation Guardrails - Enforces deterministic, multi-availability-zone resilience during autonomous Karpenter v1.0 Spot instance consolidation. Prevents simultaneous cross-AZ pod evictions by binding Karpenter disruption budgets with Kubernetes topologySpreadConstraints and strict PodDisruptionBudgets.
globs: **/*.k8s.yaml, **/*.k8s.yml, **/karpenter/**/*.yaml, **/charts/**/*.yaml, **/deployments/**/*.yaml, infra/**/*.ts, cdk/**/*.ts
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/karpenter-v1-topology-spread-consolidation-invariant"
---

# Karpenter v1.0 Quorum-Aware Topology Spread and Consolidation Guardrails

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Unbounded NodePool Consolidation Draining Cross-AZ Workloads Concurrently During Spot Reclamation

## System Constraints
You are a Principal Cloud Architect enforcing Karpenter v1.0 Zero-Pod-Disruption Topology Spread Consolidation Invariants. Autonomous node consolidation MUST NEVER degrade workload quorum or violate Availability Zone topology distribution. All Karpenter NodePool manifests and workload manifests must enforce explicit disruption budgets, minDomains topology spreads, and conservative PodDisruptionBudgets.

## Strict Guidelines
- Engineers MUST ALWAYS configure explicit `disruption.budgets` in Karpenter v1.0 `NodePool` manifests, restricting node disruption rates (e.g., `nodes: '10%'` or fixed integer limits) during peak hours or general operation.
- Engineers MUST NOT use unconstrained `consolidationPolicy: WhenEmptyOrUnderutilized` without pairing it with workload-level `topologySpreadConstraints` and `PodDisruptionBudget`.
- Workload Deployments and StatefulSets MUST enforce `topologySpreadConstraints` targeting `topology.kubernetes.io/zone` with `maxSkew: 1`, `whenUnsatisfiable: DoNotSchedule`, `nodeAffinityPolicy: Honor`, and `nodeTaintsPolicy: Honor`.
- Workloads MUST define a `PodDisruptionBudget` using `maxUnavailable: 1` or conservative `minAvailable` quotas, NEVER permitting 100% concurrent pod disruption across failure domains.
- NodePools managing Spot instances MUST define multiple AZ selections in their referenced `EC2NodeClass` subnet selectors and MUST NOT restrict workloads to a single AZ unless specifically designed as single-zone stateful nodes.
- Consolidation MUST be rate-limited using Karpenter's cron-based disruption budget windows to halt non-critical Spot consolidations during high-traffic transactional cycles.

## Bad vs Good Implementations
### Karpenter v1.0 NodePool & Deployment Topology Spread Invariant

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Karpenter is granted unrestricted authority to consolidate underutilized Spot nodes immediately without a disruption budget. The workload lacks zone topology spread constraints and a PodDisruptionBudget, enabling Karpenter to evict nodes across multiple availability zones simultaneously, violating quorum and degrading the payment service.
```yaml
# INVARIANT VIOLATION:
# 1. NodePool allows unlimited concurrent disruptions during consolidation.
# 2. Deployment lacks topologySpreadConstraints, risking all replicas landing in a single AZ.
# 3. Missing PDB or unbounded eviction risks quorum loss during Karpenter Spot reclamation.
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
  name: default-spot
spec:
  template:
    spec:
      nodeClassRef:
        group: karpenter.k8s.aws
        kind: EC2NodeClass
        name: default
      requirements:
        - key: karpenter.sh/capacity-type
          operator: In
          values: ["spot"]
  disruption:
    consolidationPolicy: WhenEmptyOrUnderutilized
    consolidateAfter: 30s
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: payment-service
spec:
  replicas: 6
  template:
    spec:
      containers:
        - name: app
          image: payment-service:v1.2.0
```

#### Production Standard (Correct)
> **Standard**: The NodePool defines an explicit disruption budget limiting concurrent node churn to 10% (and blocks disruption during core business hours). The Deployment enforces strict multi-AZ topology spread with Honor policies for node affinity/taints, and the PodDisruptionBudget guarantees that at most one pod is disrupted at any given instant during autonomous Spot consolidation.
```yaml
# PRODUCTION INVARIANT ENFORCED:
# 1. NodePool enforces strict disruption budgets and consolidation thresholds.
# 2. Deployment enforces multi-AZ topology spread with Honor policies.
# 3. PDB enforces single-replica maximum unavailability to maintain quorum.
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
  name: resilient-spot
spec:
  template:
    spec:
      nodeClassRef:
        group: karpenter.k8s.aws
        kind: EC2NodeClass
        name: default
      requirements:
        - key: karpenter.sh/capacity-type
          operator: In
          values: ["spot"]
        - key: topology.kubernetes.io/zone
          operator: In
          values: ["us-east-1a", "us-east-1b", "us-east-1c"]
  disruption:
    consolidationPolicy: WhenEmptyOrUnderutilized
    consolidateAfter: 2m
    budgets:
      - nodes: "10%"
      - schedule: "0 9 * * 1-5"
        duration: 8h
        nodes: "0"
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: payment-service-pdb
spec:
  maxUnavailable: 1
  selector:
    matchLabels:
      app: payment-service
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: payment-service
spec:
  replicas: 6
  selector:
    matchLabels:
      app: payment-service
  template:
    metadata:
      labels:
        app: payment-service
    spec:
      topologySpreadConstraints:
        - maxSkew: 1
          topologyKey: topology.kubernetes.io/zone
          whenUnsatisfiable: DoNotSchedule
          nodeAffinityPolicy: Honor
          nodeTaintsPolicy: Honor
          labelSelector:
            matchLabels:
              app: payment-service
      containers:
        - name: app
          image: payment-service:v1.2.0
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Karpenter v1.0 Quorum-Aware Topology Spread and Consolidation Guardrails

Karpenter v1.0 Quorum-Aware Topology Spread and Consolidation Guardrails defines an industrial-grade behavioral standard for devops engineering. Enforces deterministic, multi-availability-zone resilience during autonomous Karpenter v1.0 Spot instance consolidation. Prevents simultaneous cross-AZ pod evictions by binding Karpenter disruption budgets with Kubernetes topologySpreadConstraints and strict PodDisruptionBudgets. 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: Unbounded NodePool Consolidation Draining Cross-AZ Workloads Concurrently During Spot Reclamation 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 DriftUnbounded NodePool Consolidation Draining Cross-AZ Workloads Concurrently During Spot ReclamationCritical
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 configure explicit `disruption.budgets` in Karpenter v1.0 `NodePool` manifests, restricting node disruption rates (e.g., `nodes

Engineers MUST ALWAYS configure explicit `disruption.budgets` in Karpenter v1.0 `NodePool` manifests, restricting node disruption rates (e.g., `nodes: '10%'` or fixed integer limits) during peak hours or general operation.

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 use unconstrained `consolidationPolicy

Engineers MUST NOT use unconstrained `consolidationPolicy: WhenEmptyOrUnderutilized` without pairing it with workload-level `topologySpreadConstraints` and `PodDisruptionBudget`.

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

Workload Deployments and StatefulSets MUST enforce `topologySpreadConstraints` targeting `topology.kubernetes.io/zone` with `maxSkew

Workload Deployments and StatefulSets MUST enforce `topologySpreadConstraints` targeting `topology.kubernetes.io/zone` with `maxSkew: 1`, `whenUnsatisfiable: DoNotSchedule`, `nodeAffinityPolicy: Honor`, and `nodeTaintsPolicy: Honor`.

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

Workloads MUST define a `PodDisruptionBudget` using `maxUnavailable

Workloads MUST define a `PodDisruptionBudget` using `maxUnavailable: 1` or conservative `minAvailable` quotas, NEVER permitting 100% concurrent pod disruption across failure 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.
5

NodePools managing Spot instances MUST define multiple AZ selections in their referenced `EC2NodeClass` subnet selectors and MUST NOT restrict workloads to a single AZ unless specifically designed as single-zone stateful nodes.

NodePools managing Spot instances MUST define multiple AZ selections in their referenced `EC2NodeClass` subnet selectors and MUST NOT restrict workloads to a single AZ unless specifically designed as single-zone stateful nodes.

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

Consolidation MUST be rate-limited using Karpenter's cron-based disruption budget windows to halt non-critical Spot consolidations during high-traffic transactional cycles.

Consolidation MUST be rate-limited using Karpenter's cron-based disruption budget windows to halt non-critical Spot consolidations during high-traffic transactional cycles.

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 Karpenter v1.0 Quorum-Aware Topology Spread and Consolidation Guardrails critical for AI coding assistants?

Enforces deterministic, multi-availability-zone resilience during autonomous Karpenter v1.0 Spot instance consolidation. Prevents simultaneous cross-AZ pod evictions by binding Karpenter disruption budgets with Kubernetes topologySpreadConstraints and strict PodDisruptionBudgets. 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 (Unbounded NodePool Consolidation Draining Cross-AZ Workloads Concurrently During Spot Reclamation) 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

Karpenter