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

Kubernetes Gateway API BackendTLSPolicy Cryptographic Pod Verification Invariant

Enforces strict end-to-end cryptographic verification between Kubernetes Gateway API implementations and downstream Pod workloads using BackendTLSPolicy. Mandates explicit subject alternative name (SAN) hostname validation, ConfigMap-anchored Certificate Authority trust chains, and prevents unencrypted transit hops across container network interfaces (CNI) in zero-trust architectures.

Prohibited Anti-Pattern: Cleartext Service-to-Pod Transit or Insecure Skip-Verify TLS Configurations in Gateway API Topologies

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Kubernetes Gateway API BackendTLSPolicy Cryptographic Pod Verification Invariant - Enforces strict end-to-end cryptographic verification between Kubernetes Gateway API implementations and downstream Pod workloads using BackendTLSPolicy. Mandates explicit subject alternative name (SAN) hostname validation, ConfigMap-anchored Certificate Authority trust chains, and prevents unencrypted transit hops across container network interfaces (CNI) in zero-trust architectures.
globs: **/k8s/**/*.yaml, **/k8s/**/*.yml, **/manifests/**/*.yaml, **/manifests/**/*.yml, **/helm/**/*.yaml, **/helm/**/*.yml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/k8s-gateway-api-backend-tls-policy-pod-verification"
---

# Kubernetes Gateway API BackendTLSPolicy Cryptographic Pod Verification Invariant

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Cleartext Service-to-Pod Transit or Insecure Skip-Verify TLS Configurations in Gateway API Topologies

## System Constraints
You are a Principal Platform and Security Architect enforcing Kubernetes Gateway API BackendTLSPolicy Pod Verification Invariants. Mandate strict end-to-end TLS encryption from Gateway listeners to pod containers, ensuring validation of targetRefs, SAN hostnames, and CA certificate references to eliminate unencrypted transit hops across the CNI.

## Strict Guidelines
- Engineers MUST ALWAYS bind a BackendTLSPolicy (`gateway.networking.k8s.io/v1alpha3` or `v1alpha2`) to downstream Services referenced in HTTPRoute `backendRefs` when handling sensitive or regulated data.
- Engineers MUST specify an explicit, fully-qualified domain name (FQDN) in `spec.validation.hostname` matching the leaf certificate Subject Alternative Name (SAN) presented by the backend workload pods.
- Engineers MUST define `spec.validation.caCertificateRefs` pointing strictly to trusted, immutable ConfigMaps containing PEM-encoded CA bundles; wildcards and unverified certificate authorities are prohibited.
- Engineers MUST NOT disable TLS verification, rely on self-signed certificates without an explicit ConfigMap anchor, or use `insecureSkipVerify` annotations supported by non-conforming ingress controllers.
- Services targeted by `targetRefs` MUST route traffic exclusively to Pod ports serving valid TLS certificates generated by an enterprise PKI (e.g., cert-manager, HashiCorp Vault, or SPIFFE/SPIRE).
- Network policies and Gateway listeners MUST NEVER fallback to plaintext HTTP (port 80/8080) for pod transit under any route fallback scenario.

## Bad vs Good Implementations
### Configuring BackendTLSPolicy for Cryptographic Pod Verification

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The HTTPRoute sends traffic to an unencrypted service endpoint (port 8080) without a BackendTLSPolicy. Packets traversing node-to-node virtual interfaces or overlay networks are fully unencrypted, exposing credentials and sensitive payloads to adjacent containers or compromised nodes.
```yaml
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: payment-service-route
  namespace: payments
spec:
  parentRefs:
    - name: internal-gateway
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /api/v1/checkout
      backendRefs:
        # CRITICAL VULNERABILITY: Traffic from Gateway to Service/Pod travels in cleartext over CNI.
        # Node-to-node eavesdropping can intercept decrypted payment card data.
        - name: payment-backend
          port: 8080
```

#### Production Standard (Correct)
> **Standard**: The Gateway API BackendTLSPolicy is explicitly attached to the target Service, binding port 8443 to strict TLS validation. It enforces that the downstream Pod serves a certificate matching 'payment-backend.payments.svc.cluster.local' signed by the trusted authority provided in the 'internal-ca-bundle' ConfigMap.
```yaml
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: payment-service-route
  namespace: payments
spec:
  parentRefs:
    - name: internal-gateway
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /api/v1/checkout
      backendRefs:
        - name: payment-backend
          port: 8443
---
apiVersion: gateway.networking.k8s.io/v1alpha3
kind: BackendTLSPolicy
metadata:
  name: payment-backend-tls
  namespace: payments
spec:
  targetRefs:
    - group: ""
      kind: Service
      name: payment-backend
  validation:
    # Enforces cryptographic pod identity via SAN matching
    hostname: payment-backend.payments.svc.cluster.local
    caCertificateRefs:
      - group: ""
        kind: ConfigMap
        name: internal-ca-bundle
```

Recommended MCP Servers (mcp-serverlist.com)

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

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Kubernetes Gateway API BackendTLSPolicy Cryptographic Pod Verification Invariant

Kubernetes Gateway API BackendTLSPolicy Cryptographic Pod Verification Invariant defines an industrial-grade behavioral standard for devops engineering. Enforces strict end-to-end cryptographic verification between Kubernetes Gateway API implementations and downstream Pod workloads using BackendTLSPolicy. Mandates explicit subject alternative name (SAN) hostname validation, ConfigMap-anchored Certificate Authority trust chains, and prevents unencrypted transit hops across container network interfaces (CNI) in zero-trust architectures. 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: Cleartext Service-to-Pod Transit or Insecure Skip-Verify TLS Configurations in Gateway API Topologies 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 DriftCleartext Service-to-Pod Transit or Insecure Skip-Verify TLS Configurations in Gateway API TopologiesCritical
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 a BackendTLSPolicy (`gateway.networking.k8s.io/v1alpha3` or `v1alpha2`) to downstream Services referenced in HTTPRoute `backendRefs` when handling sensitive or regulated data.

Engineers MUST ALWAYS bind a BackendTLSPolicy (`gateway.networking.k8s.io/v1alpha3` or `v1alpha2`) to downstream Services referenced in HTTPRoute `backendRefs` when handling sensitive or regulated data.

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 specify an explicit, fully-qualified domain name (FQDN) in `spec.validation.hostname` matching the leaf certificate Subject Alternative Name (SAN) presented by the backend workload pods.

Engineers MUST specify an explicit, fully-qualified domain name (FQDN) in `spec.validation.hostname` matching the leaf certificate Subject Alternative Name (SAN) presented by the backend workload pods.

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 define `spec.validation.caCertificateRefs` pointing strictly to trusted, immutable ConfigMaps containing PEM-encoded CA bundles

Engineers MUST define `spec.validation.caCertificateRefs` pointing strictly to trusted, immutable ConfigMaps containing PEM-encoded CA bundles; wildcards and unverified certificate authorities are prohibited.

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 NOT disable TLS verification, rely on self-signed certificates without an explicit ConfigMap anchor, or use `insecureSkipVerify` annotations supported by non-conforming ingress controllers.

Engineers MUST NOT disable TLS verification, rely on self-signed certificates without an explicit ConfigMap anchor, or use `insecureSkipVerify` annotations supported by non-conforming ingress controllers.

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 targeted by `targetRefs` MUST route traffic exclusively to Pod ports serving valid TLS certificates generated by an enterprise PKI (e.g., cert-manager, HashiCorp Vault, or SPIFFE/SPIRE).

Services targeted by `targetRefs` MUST route traffic exclusively to Pod ports serving valid TLS certificates generated by an enterprise PKI (e.g., cert-manager, HashiCorp Vault, or SPIFFE/SPIRE).

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

Network policies and Gateway listeners MUST NEVER fallback to plaintext HTTP (port 80/8080) for pod transit under any route fallback scenario.

Network policies and Gateway listeners MUST NEVER fallback to plaintext HTTP (port 80/8080) for pod transit under any route fallback scenario.

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 BackendTLSPolicy Cryptographic Pod Verification Invariant critical for AI coding assistants?

Enforces strict end-to-end cryptographic verification between Kubernetes Gateway API implementations and downstream Pod workloads using BackendTLSPolicy. Mandates explicit subject alternative name (SAN) hostname validation, ConfigMap-anchored Certificate Authority trust chains, and prevents unencrypted transit hops across container network interfaces (CNI) in zero-trust architectures. 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 (Cleartext Service-to-Pod Transit or Insecure Skip-Verify TLS Configurations in Gateway API Topologies) 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