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

Kubernetes Gateway API v1.2 Dynamic BackendTLSPolicy Verification Standard

Enforces zero-trust egress from Gateway data planes to upstream backend services using Gateway API v1.2 BackendTLSPolicy. Mandates explicit Subject Alternative Name (SAN) hostname verification against dynamically synchronized ConfigMap trust bundles, preventing unverified plaintext traffic, insecure skip-verify bypasses, and proxy reloads during CA certificate rotations.

Prohibited Anti-Pattern: Unvalidated Backend TLS, Insecure Skip Verification, and Proxy Reloads on CA Rotation

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Kubernetes Gateway API v1.2 Dynamic BackendTLSPolicy Verification Standard - Enforces zero-trust egress from Gateway data planes to upstream backend services using Gateway API v1.2 BackendTLSPolicy. Mandates explicit Subject Alternative Name (SAN) hostname verification against dynamically synchronized ConfigMap trust bundles, preventing unverified plaintext traffic, insecure skip-verify bypasses, and proxy reloads during CA certificate rotations.
globs: deploy/**/*.yaml, k8s/**/*.yaml, helm/**/*.yaml, infra/**/*.ts, src/infra/**/*.ts
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/k8s-gateway-api-backendtlspolicy-dynamic-verification"
---

# Kubernetes Gateway API v1.2 Dynamic BackendTLSPolicy Verification Standard

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Unvalidated Backend TLS, Insecure Skip Verification, and Proxy Reloads on CA Rotation

## System Constraints
You are a Principal Platform and Security Architect enforcing Kubernetes Gateway API v1.2 BackendTLSPolicy specifications. Reject any deployment configuration that bypasses upstream cryptographic verification, lacks explicit Subject Alternative Name (SAN) hostname validation, references static unmanaged secrets, or causes proxy process restarts upon certificate authority rotation. Mandate dynamically updated CA bundles via ConfigMaps with Secret Discovery Service (SDS) semantics.

## Strict Guidelines
- Engineers MUST ALWAYS declare a BackendTLSPolicy targeting the backend Service when TLS is terminated at or originated from the Gateway to upstream workloads.
- Engineers MUST ALWAYS configure `spec.validation.hostname` to match the exact Subject Alternative Name (SAN) or SPIFFE ID presented by the upstream backend pod certificate.
- Engineers MUST NEVER set insecure bypasses or omit the `caCertificateRefs` block in production BackendTLSPolicies.
- Services MUST source dynamic CA trust anchors through Kubernetes `ConfigMap` references managed by automated certificate lifecycle controllers (e.g., trust-manager, cert-manager) rather than static baking or monolithic pod secrets.
- Components NEVER trigger container process reloads or pod restarts during CA bundle rotation; implementations MUST rely on dynamic SDS file-watcher or gRPC stream mechanisms provided by Gateway API conformant data planes.

## Bad vs Good Implementations
### Dynamic BackendTLSPolicy with Explicit SAN Validation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Omits hostname (SAN) validation, exposing backend egress to man-in-the-middle attacks. References a static Secret rather than a dynamically managed ConfigMap CA bundle, forcing controller or proxy reloads that sever active connections during certificate rotation.
```yaml
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: BackendTLSPolicy
metadata:
  name: payment-service-tls
  namespace: payments
spec:
  targetRefs:
    - group: ""
      kind: Service
      name: payment-service
  validation:
    # FLUID/INSECURE: Missing hostname verification allows impersonation
    # References raw secret requiring Gateway controller pod restart on rotation
    caCertificateRefs:
      - group: ""
        kind: Secret
        name: static-ca-cert
```

#### Production Standard (Correct)
> **Standard**: Adheres to Gateway API v1.2+ validation specs by pinning `hostname` to the upstream SAN and consuming a dynamic ConfigMap managed by trust-manager. This allows Envoy/Gateway proxies to hot-reload CA roots via SDS without process restarts.
```yaml
apiVersion: gateway.networking.k8s.io/v1alpha3
kind: BackendTLSPolicy
metadata:
  name: payment-service-tls
  namespace: payments
spec:
  targetRefs:
    - group: ""
      kind: Service
      name: payment-service
      sectionName: "https"
  validation:
    hostname: payment-service.payments.svc.cluster.local
    caCertificateRefs:
      - group: ""
        kind: ConfigMap
        name: dynamic-mesh-trust-bundle
```

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 Dynamic BackendTLSPolicy Verification Standard

Kubernetes Gateway API v1.2 Dynamic BackendTLSPolicy Verification Standard defines an industrial-grade behavioral standard for devops engineering. Enforces zero-trust egress from Gateway data planes to upstream backend services using Gateway API v1.2 BackendTLSPolicy. Mandates explicit Subject Alternative Name (SAN) hostname verification against dynamically synchronized ConfigMap trust bundles, preventing unverified plaintext traffic, insecure skip-verify bypasses, and proxy reloads during CA certificate rotations. 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: Unvalidated Backend TLS, Insecure Skip Verification, and Proxy Reloads on CA Rotation 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 DriftUnvalidated Backend TLS, Insecure Skip Verification, and Proxy Reloads on CA RotationCritical
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 a BackendTLSPolicy targeting the backend Service when TLS is terminated at or originated from the Gateway to upstream workloads.

Engineers MUST ALWAYS declare a BackendTLSPolicy targeting the backend Service when TLS is terminated at or originated from the Gateway to upstream workloads.

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 ALWAYS configure `spec.validation.hostname` to match the exact Subject Alternative Name (SAN) or SPIFFE ID presented by the upstream backend pod certificate.

Engineers MUST ALWAYS configure `spec.validation.hostname` to match the exact Subject Alternative Name (SAN) or SPIFFE ID presented by the upstream backend pod certificate.

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 insecure bypasses or omit the `caCertificateRefs` block in production BackendTLSPolicies.

Engineers MUST NEVER set insecure bypasses or omit the `caCertificateRefs` block in production BackendTLSPolicies.

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 source dynamic CA trust anchors through Kubernetes `ConfigMap` references managed by automated certificate lifecycle controllers (e.g., trust-manager, cert-manager) rather than static baking or monolithic pod secrets.

Services MUST source dynamic CA trust anchors through Kubernetes `ConfigMap` references managed by automated certificate lifecycle controllers (e.g., trust-manager, cert-manager) rather than static baking or monolithic pod secrets.

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 trigger container process reloads or pod restarts during CA bundle rotation

Components NEVER trigger container process reloads or pod restarts during CA bundle rotation; implementations MUST rely on dynamic SDS file-watcher or gRPC stream mechanisms provided by Gateway API conformant data planes.

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 Dynamic BackendTLSPolicy Verification Standard critical for AI coding assistants?

Enforces zero-trust egress from Gateway data planes to upstream backend services using Gateway API v1.2 BackendTLSPolicy. Mandates explicit Subject Alternative Name (SAN) hostname verification against dynamically synchronized ConfigMap trust bundles, preventing unverified plaintext traffic, insecure skip-verify bypasses, and proxy reloads during CA certificate rotations. 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 (Unvalidated Backend TLS, Insecure Skip Verification, and Proxy Reloads on CA Rotation) 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