This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: envoy-gateway-dynamic-outlier-detection-circuit-breaking

Envoy Gateway 1.2+ Dynamic Outlier Detection & Egress Circuit-Breaking Standard

Enforces deterministic outlier detection and egress circuit breaking via Envoy Gateway 1.2+ BackendTrafficPolicy CRDs across all canary and upstream service meshes. Proactively isolates failing pods and halts cascading failovers during statistical anomaly windows while preserving baseline traffic availability.

Prohibited Anti-Pattern: Unbounded Egress Retries Without Outlier Detection Triggering Canary Collapse

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Envoy Gateway 1.2+ Dynamic Outlier Detection & Egress Circuit-Breaking Standard - Enforces deterministic outlier detection and egress circuit breaking via Envoy Gateway 1.2+ BackendTrafficPolicy CRDs across all canary and upstream service meshes. Proactively isolates failing pods and halts cascading failovers during statistical anomaly windows while preserving baseline traffic availability.
globs: **/k8s/**/*.yaml, **/manifests/**/*.yaml, **/gateway/**/*.yaml, **/helm/**/*.yaml, deploy/**/*.{yaml,yml}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/envoy-gateway-dynamic-outlier-detection-circuit-breaking"
---

# Envoy Gateway 1.2+ Dynamic Outlier Detection & Egress Circuit-Breaking Standard

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Unbounded Egress Retries Without Outlier Detection Triggering Canary Collapse

## System Constraints
You are a Principal Infrastructure Architect enforcing resilient ingress/egress configurations using Envoy Gateway 1.2+. You must ensure every HTTPRoute and Backend reference is safeguarded with a dedicated BackendTrafficPolicy that mandates statistical outlier detection, ejection safety bounds, and connection pool saturation limits to arrest cascading topology failures.

## Strict Guidelines
- Engineers MUST ALWAYS attach a valid `BackendTrafficPolicy` (API version `gateway.envoyproxy.io/v1alpha1`) to target HTTPRoutes referencing upstream services.
- Engineers MUST configure `outlierDetection` with both `consecutive5xxErrors` and explicit interval/base ejection windows to remove degraded pods deterministically.
- Engineers MUST NEVER set `maxEjectionPercent` higher than 50% in production to prevent complete cluster starvation under systemic network partition.
- Engineers MUST define explicit `circuitBreaker` thresholds for `maxConnections`, `maxPendingRequests`, and `maxRequests` to prevent upstream connection queue saturation.
- Services MUST declare split canary weights using distinct TargetRefs or Backend clusters to allow outlier detection to isolate canary instances independently.

## Bad vs Good Implementations
### Unbounded Route Configuration with Default Retries (Vulnerable)

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Routing traffic to canary pods without an accompanying BackendTrafficPolicy allows failing or slow canary replicas to consume all gateway connection buffers, causing cascading timeouts to healthy baseline pods.
```yaml
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: order-service-route
  namespace: production
spec:
  parentRefs:
    - name: eg-gateway
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /api/v1/orders
      backendRefs:
        - name: order-service-baseline
          port: 8080
          weight: 90
        - name: order-service-canary
          port: 8080
          weight: 10
# Missing BackendTrafficPolicy: canary failures will exhaust gateway connection pools
# and trigger cascading gateway-wide 503 errors.
```

#### Production Standard (Correct)
> **Standard**: The BackendTrafficPolicy enforces connection and pending request bounds alongside proactive outlier detection. If canary pods emit consecutive 5xx/gateway errors within 10 seconds, Envoy dynamically ejects them for 30 seconds up to a safe 50% cap.
```yaml
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: order-service-route
  namespace: production
spec:
  parentRefs:
    - name: eg-gateway
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /api/v1/orders
      backendRefs:
        - name: order-service-baseline
          port: 8080
          weight: 90
        - name: order-service-canary
          port: 8080
          weight: 10
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
  name: order-service-resilience
  namespace: production
spec:
  targetRefs:
    - group: gateway.networking.k8s.io
      kind: HTTPRoute
      name: order-service-route
  circuitBreaker:
    maxConnections: 1024
    maxPendingRequests: 128
    maxRequests: 2048
    maxRetries: 3
  outlierDetection:
    consecutive5xxErrors: 3
    interval: 10s
    baseEjectionTime: 30s
    maxEjectionPercent: 50
    consecutiveGatewayErrors: 3
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Envoy Gateway 1.2+ Dynamic Outlier Detection & Egress Circuit-Breaking Standard

Envoy Gateway 1.2+ Dynamic Outlier Detection & Egress Circuit-Breaking Standard defines an industrial-grade behavioral standard for devops engineering. Enforces deterministic outlier detection and egress circuit breaking via Envoy Gateway 1.2+ BackendTrafficPolicy CRDs across all canary and upstream service meshes. Proactively isolates failing pods and halts cascading failovers during statistical anomaly windows while preserving baseline traffic availability. 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 Egress Retries Without Outlier Detection Triggering Canary Collapse 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 Egress Retries Without Outlier Detection Triggering Canary CollapseCritical
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 attach a valid `BackendTrafficPolicy` (API version `gateway.envoyproxy.io/v1alpha1`) to target HTTPRoutes referencing upstream services.

Engineers MUST ALWAYS attach a valid `BackendTrafficPolicy` (API version `gateway.envoyproxy.io/v1alpha1`) to target HTTPRoutes referencing upstream services.

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 configure `outlierDetection` with both `consecutive5xxErrors` and explicit interval/base ejection windows to remove degraded pods deterministically.

Engineers MUST configure `outlierDetection` with both `consecutive5xxErrors` and explicit interval/base ejection windows to remove degraded pods deterministically.

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

Engineers MUST NEVER set `maxEjectionPercent` higher than 50% in production to prevent complete cluster starvation under systemic network partition.

Engineers MUST NEVER set `maxEjectionPercent` higher than 50% in production to prevent complete cluster starvation under systemic network partition.

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

Engineers MUST define explicit `circuitBreaker` thresholds for `maxConnections`, `maxPendingRequests`, and `maxRequests` to prevent upstream connection queue saturation.

Engineers MUST define explicit `circuitBreaker` thresholds for `maxConnections`, `maxPendingRequests`, and `maxRequests` to prevent upstream connection queue saturation.

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 declare split canary weights using distinct TargetRefs or Backend clusters to allow outlier detection to isolate canary instances independently.

Services MUST declare split canary weights using distinct TargetRefs or Backend clusters to allow outlier detection to isolate canary instances independently.

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 Envoy Gateway 1.2+ Dynamic Outlier Detection & Egress Circuit-Breaking Standard critical for AI coding assistants?

Enforces deterministic outlier detection and egress circuit breaking via Envoy Gateway 1.2+ BackendTrafficPolicy CRDs across all canary and upstream service meshes. Proactively isolates failing pods and halts cascading failovers during statistical anomaly windows while preserving baseline traffic availability. 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 Egress Retries Without Outlier Detection Triggering Canary Collapse) 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

Envoy