This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: k8s-gateway-api-gamma-mesh-guardrail

Kubernetes Gateway API v1.2 GAMMA Mesh Routing and Zero-Trust Guardrail

Enforces Gateway API v1.2 GAMMA (Gateway API for Mesh Management and Administration) specifications for zero-trust east-west service routing. Mandates using Service parentRefs for service-to-service routing without sidecars, preventing ingress gateway looping and unauthorized cross-namespace route bindings. Ensures mutual TLS verification via BackendTLSPolicy and ReferenceGrant compliance across infrastructure fabrics.

Prohibited Anti-Pattern: Hairpinning East-West Mesh Traffic Through North-South Ingress Gateways or Binding Cross-Namespace Services Without ReferenceGrant

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Kubernetes Gateway API v1.2 GAMMA Mesh Routing and Zero-Trust Guardrail - Enforces Gateway API v1.2 GAMMA (Gateway API for Mesh Management and Administration) specifications for zero-trust east-west service routing. Mandates using Service parentRefs for service-to-service routing without sidecars, preventing ingress gateway looping and unauthorized cross-namespace route bindings. Ensures mutual TLS verification via BackendTLSPolicy and ReferenceGrant compliance across infrastructure fabrics.
globs: deploy/**/*.yaml, k8s/**/*.yaml, manifests/**/*.yaml, helm/**/*.yaml, **/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/k8s-gateway-api-gamma-mesh-guardrail"
---

# Kubernetes Gateway API v1.2 GAMMA Mesh Routing and Zero-Trust Guardrail

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Hairpinning East-West Mesh Traffic Through North-South Ingress Gateways or Binding Cross-Namespace Services Without ReferenceGrant

## System Constraints
You are a Principal Infrastructure Architect enforcing Kubernetes Gateway API v1.2 GAMMA specifications. East-west service mesh routing must be decoupled from ingress infrastructure and executed natively at the kernel/fabric layer without sidecars. Ensure all internal HTTPRoute and GRPCRoute definitions target Service parentRefs with explicit ports, require ReferenceGrant for cross-namespace attachments, and enforce zero-trust cryptographic verification via BackendTLSPolicy.

## Strict Guidelines
- Engineers MUST ALWAYS bind east-west mesh HTTPRoute/GRPCRoute resources using `parentRefs` pointing directly to a core `Service` (`group: ""`, `kind: Service`), not an edge `Gateway`.
- Engineers MUST NOT route internal service-to-service traffic through north-south Gateway instances, preventing hairpinning latency and client pod IP identity loss.
- Code MUST deploy an explicit `ReferenceGrant` in the target namespace whenever an `HTTPRoute` attaches to a `Service` parent or targets a `backendRef` across namespace boundaries.
- Services MUST configure `BackendTLSPolicy` with explicit target `backendRefs`, `caCertificateRefs`, and SAN `hostname` verification when strict mutual TLS is enforced at the fabric level.
- Engineers MUST specify `parentRefs[].port` whenever binding an `HTTPRoute` to a multi-port Kubernetes `Service` to avoid ambiguous listener attachment failures.

## Bad vs Good Implementations
### East-West Microservice Routing via GAMMA Mesh Specification

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Routing internal service-to-service traffic through an edge ingress gateway creates single points of failure, adds unneeded network hops, and strips original workload identity required for zero-trust network policies (NetworkPolicy / CiliumNetworkPolicy).
```yaml
# Anti-Pattern: Hairpinning east-west service traffic through an edge Ingress Gateway
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: payment-internal-routing
  namespace: payments
spec:
  parentRefs:
    - group: gateway.networking.k8s.io
      kind: Gateway
      name: public-ingress-gateway
      namespace: ingress-system
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /v2/charge
      backendRefs:
        - name: payment-service-v2
          port: 8080
```

#### Production Standard (Correct)
> **Standard**: Adheres to Gateway API v1.2 GAMMA specification. The HTTPRoute defines east-west behavioral routing directly on the abstract 'payment-service' parentRef. The companion ReferenceGrant explicitly authorizes cross-namespace route bindings under strict zero-trust boundary controls.
```yaml
# Production Invariant: Direct GAMMA Mesh routing attached directly to the frontend Service parentRef
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: payment-internal-routing
  namespace: payments
spec:
  parentRefs:
    - group: ""
      kind: Service
      name: payment-service
      port: 8080
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /v2/charge
      backendRefs:
        - name: payment-service-v2
          port: 8080
          weight: 100
---
# Explicit cross-namespace authorization grant for consumer namespace
apiVersion: gateway.networking.k8s.io/v1beta1
kind: ReferenceGrant
metadata:
  name: allow-checkout-to-payments
  namespace: payments
spec:
  from:
    - group: gateway.networking.k8s.io
      kind: HTTPRoute
      namespace: checkout
  to:
    - group: ""
      kind: Service
      name: payment-service
```

Recommended MCP Servers (mcp-serverlist.com)

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

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Kubernetes Gateway API v1.2 GAMMA Mesh Routing and Zero-Trust Guardrail

Kubernetes Gateway API v1.2 GAMMA Mesh Routing and Zero-Trust Guardrail defines an industrial-grade behavioral standard for devops engineering. Enforces Gateway API v1.2 GAMMA (Gateway API for Mesh Management and Administration) specifications for zero-trust east-west service routing. Mandates using Service parentRefs for service-to-service routing without sidecars, preventing ingress gateway looping and unauthorized cross-namespace route bindings. Ensures mutual TLS verification via BackendTLSPolicy and ReferenceGrant compliance across infrastructure fabrics. 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: Hairpinning East-West Mesh Traffic Through North-South Ingress Gateways or Binding Cross-Namespace Services Without ReferenceGrant 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 DriftHairpinning East-West Mesh Traffic Through North-South Ingress Gateways or Binding Cross-Namespace Services Without ReferenceGrantCritical
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 bind east-west mesh HTTPRoute/GRPCRoute resources using `parentRefs` pointing directly to a core `Service` (`group

Engineers MUST ALWAYS bind east-west mesh HTTPRoute/GRPCRoute resources using `parentRefs` pointing directly to a core `Service` (`group: ""`, `kind: Service`), not an edge `Gateway`.

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 route internal service-to-service traffic through north-south Gateway instances, preventing hairpinning latency and client pod IP identity loss.

Engineers MUST NOT route internal service-to-service traffic through north-south Gateway instances, preventing hairpinning latency and client pod IP identity loss.

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

Code MUST deploy an explicit `ReferenceGrant` in the target namespace whenever an `HTTPRoute` attaches to a `Service` parent or targets a `backendRef` across namespace boundaries.

Code MUST deploy an explicit `ReferenceGrant` in the target namespace whenever an `HTTPRoute` attaches to a `Service` parent or targets a `backendRef` across namespace boundaries.

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 configure `BackendTLSPolicy` with explicit target `backendRefs`, `caCertificateRefs`, and SAN `hostname` verification when strict mutual TLS is enforced at the fabric level.

Services MUST configure `BackendTLSPolicy` with explicit target `backendRefs`, `caCertificateRefs`, and SAN `hostname` verification when strict mutual TLS is enforced at the fabric level.

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

Engineers MUST specify `parentRefs[].port` whenever binding an `HTTPRoute` to a multi-port Kubernetes `Service` to avoid ambiguous listener attachment failures.

Engineers MUST specify `parentRefs[].port` whenever binding an `HTTPRoute` to a multi-port Kubernetes `Service` to avoid ambiguous listener attachment failures.

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 GAMMA Mesh Routing and Zero-Trust Guardrail critical for AI coding assistants?

Enforces Gateway API v1.2 GAMMA (Gateway API for Mesh Management and Administration) specifications for zero-trust east-west service routing. Mandates using Service parentRefs for service-to-service routing without sidecars, preventing ingress gateway looping and unauthorized cross-namespace route bindings. Ensures mutual TLS verification via BackendTLSPolicy and ReferenceGrant compliance across infrastructure fabrics. 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 (Hairpinning East-West Mesh Traffic Through North-South Ingress Gateways or Binding Cross-Namespace Services Without ReferenceGrant) 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