This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: k8s-gateway-v1-2-cross-mesh-failover-invariant

Kubernetes Gateway API v1.2 Multi-Cluster Cross-Mesh Failover and Resilience Invariant

Enforces vendor-neutral multi-cluster routing, cross-cloud failover, and active resiliency contracts exclusively using Kubernetes Gateway API v1.2 specification primitives. Prohibits reliance on proprietary service mesh CRDs (such as Istio VirtualService/DestinationRule or Linkerd TrafficSplit), mandating HTTPRoute backendRefs, ServiceImport targeting, explicit ReferenceGrants, and standard request timeouts.

Prohibited Anti-Pattern: Proprietary Mesh Lock-in via Vendor CRDs for Ingress Failover and Cross-Cluster Routing

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Kubernetes Gateway API v1.2 Multi-Cluster Cross-Mesh Failover and Resilience Invariant - Enforces vendor-neutral multi-cluster routing, cross-cloud failover, and active resiliency contracts exclusively using Kubernetes Gateway API v1.2 specification primitives. Prohibits reliance on proprietary service mesh CRDs (such as Istio VirtualService/DestinationRule or Linkerd TrafficSplit), mandating HTTPRoute backendRefs, ServiceImport targeting, explicit ReferenceGrants, and standard request timeouts.
globs: deploy/**/*.yaml, k8s/**/*.yaml, helm/**/*.yaml, infra/**/*.ts, manifests/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/k8s-gateway-v1-2-cross-mesh-failover-invariant"
---

# Kubernetes Gateway API v1.2 Multi-Cluster Cross-Mesh Failover and Resilience Invariant

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Proprietary Mesh Lock-in via Vendor CRDs for Ingress Failover and Cross-Cluster Routing

## System Constraints
You are a Principal Cloud-Native Architect and Platform Security Engineer enforcing Kubernetes Gateway API v1.2 standards across all multi-cluster and cross-mesh routing boundaries.

Mandate the following architectural invariants:
1. Zero Vendor Lock-in: Explicitly reject proprietary mesh CRDs (such as networking.istio.io/v1alpha3 VirtualService, DestinationRule, EnvoyFilter, or split.smi-spec.io/v1alpha1 TrafficSplit) for ingress failover and traffic management.
2. Kubernetes Gateway API v1.2 Compliance: Multi-cluster ingress and egress traffic MUST be expressed using gateway.networking.k8s.io/v1 Gateway and HTTPRoute resources.
3. Cross-Cluster Topology Contract: Multi-cluster failover backends MUST target standard multicluster.x-k8s.io ServiceImport objects via HTTPRoute backendRefs with explicit weights.
4. Cross-Namespace Isolation: Any route resolving backends or secrets across namespace boundaries MUST be backed by a corresponding gateway.networking.k8s.io/v1beta1 ReferenceGrant in the target namespace.
5. Deterministic Resiliency: All HTTPRoute rules MUST explicitly declare timeouts (request and backendRequest) at the route level to prevent cascading connection pool exhaustion during upstream cloud-region partitioning.

## Strict Guidelines
- Engineers MUST ALWAYS use gateway.networking.k8s.io/v1 HTTPRoute for ingress routing, traffic splitting, and weighted cross-cluster failover.
- Engineers MUST NOT deploy vendor-proprietary CRDs (e.g., Istio DestinationRule, VirtualService, or Linkerd ServiceProfile) for traffic routing or failover policies.
- Multi-cluster backend targets MUST reference group: multicluster.x-k8s.io and kind: ServiceImport within HTTPRoute.spec.rules.backendRefs.
- Cross-namespace backendRefs and Certificate references MUST ALWAYS be authorized by an explicit gateway.networking.k8s.io/v1beta1 ReferenceGrant in the referenced namespace.
- HTTPRoute rules MUST declare standard spec.rules[].timeouts containing both request and backendRequest limits to guard against silent cross-cloud timeouts.
- Backend weighted distribution MUST ensure failover targets define non-zero integer weights or prioritized rule ordering without vendor-specific traffic policy annotations.

## Bad vs Good Implementations
### Vendor-Proprietary Service Mesh Routing vs. Gateway API v1.2 Multi-Cluster Invariant

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Relies on proprietary Istio CRDs (VirtualService, DestinationRule, and pseudo-TLD '.global') that break when migrating clouds or changing ingress controllers. It lacks declarative cross-namespace trust grants and standardized multi-cluster service abstraction.
```yaml
# VENDOR LOCK-IN ANTI-PATTERN: Proprietary Istio CRD for multi-cluster failover
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: checkout-failover-route
  namespace: production
spec:
  hosts:
    - checkout.platform.internal
  gateways:
    - cross-cloud-gateway
  http:
    - route:
        - destination:
            host: checkout-primary.production.svc.cluster.local
            weight: 90
        - destination:
            # Non-standard cross-cluster address bound to vendor-specific mesh endpoint discovery
            host: checkout.production.global
            weight: 10
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: checkout-circuit-breaker
  namespace: production
spec:
  host: checkout-primary.production.svc.cluster.local
  trafficPolicy:
    outlierDetection:
      consecutive5xxErrors: 3
      interval: 10s
      baseEjectionTime: 30s
```

#### Production Standard (Correct)
> **Standard**: Implements standard Kubernetes Gateway API v1.2 constructs. It targets a vendor-neutral ServiceImport (KEP-1645 Multi-Cluster Services) for cross-cloud failover, secures boundaries using ReferenceGrant, and enforces deterministic timeouts directly in the route spec.
```yaml
# STANDARDIZED INVARIANT: Gateway API v1.2 Multi-Cluster ServiceImport Failover
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: checkout-failover-route
  namespace: edge-routing
spec:
  parentRefs:
    - group: gateway.networking.k8s.io
      kind: Gateway
      name: edge-gateway
      sectionName: https
  hostnames:
    - "checkout.platform.internal"
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /
      timeouts:
        request: 5s
        backendRequest: 2s
      backendRefs:
        - group: ""
          kind: Service
          name: checkout-primary
          namespace: checkout-workloads
          port: 8080
          weight: 90
        - group: multicluster.x-k8s.io
          kind: ServiceImport
          name: checkout-secondary-dr
          namespace: checkout-workloads
          port: 8080
          weight: 10
---
# Explicit cross-namespace authorization required by Gateway API
apiVersion: gateway.networking.k8s.io/v1beta1
kind: ReferenceGrant
metadata:
  name: allow-edge-to-checkout
  namespace: checkout-workloads
spec:
  from:
    - group: gateway.networking.k8s.io
      kind: HTTPRoute
      namespace: edge-routing
  to:
    - group: ""
      kind: Service
    - group: multicluster.x-k8s.io
      kind: ServiceImport
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Kubernetes Gateway API v1.2 Multi-Cluster Cross-Mesh Failover and Resilience Invariant

Kubernetes Gateway API v1.2 Multi-Cluster Cross-Mesh Failover and Resilience Invariant defines an industrial-grade behavioral standard for devops engineering. Enforces vendor-neutral multi-cluster routing, cross-cloud failover, and active resiliency contracts exclusively using Kubernetes Gateway API v1.2 specification primitives. Prohibits reliance on proprietary service mesh CRDs (such as Istio VirtualService/DestinationRule or Linkerd TrafficSplit), mandating HTTPRoute backendRefs, ServiceImport targeting, explicit ReferenceGrants, and standard request timeouts. 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: Proprietary Mesh Lock-in via Vendor CRDs for Ingress Failover and Cross-Cluster Routing 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 DriftProprietary Mesh Lock-in via Vendor CRDs for Ingress Failover and Cross-Cluster RoutingCritical
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 use gateway.networking.k8s.io/v1 HTTPRoute for ingress routing, traffic splitting, and weighted cross-cluster failover.

Engineers MUST ALWAYS use gateway.networking.k8s.io/v1 HTTPRoute for ingress routing, traffic splitting, and weighted cross-cluster failover.

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 deploy vendor-proprietary CRDs (e.g., Istio DestinationRule, VirtualService, or Linkerd ServiceProfile) for traffic routing or failover policies.

Engineers MUST NOT deploy vendor-proprietary CRDs (e.g., Istio DestinationRule, VirtualService, or Linkerd ServiceProfile) for traffic routing or failover policies.

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

Multi-cluster backend targets MUST reference group

Multi-cluster backend targets MUST reference group: multicluster.x-k8s.io and kind: ServiceImport within HTTPRoute.spec.rules.backendRefs.

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

Cross-namespace backendRefs and Certificate references MUST ALWAYS be authorized by an explicit gateway.networking.k8s.io/v1beta1 ReferenceGrant in the referenced namespace.

Cross-namespace backendRefs and Certificate references MUST ALWAYS be authorized by an explicit gateway.networking.k8s.io/v1beta1 ReferenceGrant in the referenced namespace.

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

HTTPRoute rules MUST declare standard spec.rules[].timeouts containing both request and backendRequest limits to guard against silent cross-cloud timeouts.

HTTPRoute rules MUST declare standard spec.rules[].timeouts containing both request and backendRequest limits to guard against silent cross-cloud timeouts.

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

Backend weighted distribution MUST ensure failover targets define non-zero integer weights or prioritized rule ordering without vendor-specific traffic policy annotations.

Backend weighted distribution MUST ensure failover targets define non-zero integer weights or prioritized rule ordering without vendor-specific traffic policy annotations.

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 Gateway API v1.2 Multi-Cluster Cross-Mesh Failover and Resilience Invariant critical for AI coding assistants?

Enforces vendor-neutral multi-cluster routing, cross-cloud failover, and active resiliency contracts exclusively using Kubernetes Gateway API v1.2 specification primitives. Prohibits reliance on proprietary service mesh CRDs (such as Istio VirtualService/DestinationRule or Linkerd TrafficSplit), mandating HTTPRoute backendRefs, ServiceImport targeting, explicit ReferenceGrants, and standard request timeouts. 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 (Proprietary Mesh Lock-in via Vendor CRDs for Ingress Failover and Cross-Cluster Routing) 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