This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: cilium-ebpf-host-routing-wireguard-mesh-invariant

Cilium eBPF Host-Routing WireGuard Mesh Invariant

Enforces transparent in-kernel packet encryption via Cilium eBPF host-routing and WireGuard mesh, bypassing the Linux network stack and user-space proxy overhead. Guarantees end-to-end cryptographic isolation and strict mutual authentication across tenant namespace boundaries without requiring Istio or Linkerd sidecars.

Prohibited Anti-Pattern: Injecting user-space sidecar proxies for mTLS encryption and leaving eBPF host-routing disabled

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium eBPF Host-Routing WireGuard Mesh Invariant - Enforces transparent in-kernel packet encryption via Cilium eBPF host-routing and WireGuard mesh, bypassing the Linux network stack and user-space proxy overhead. Guarantees end-to-end cryptographic isolation and strict mutual authentication across tenant namespace boundaries without requiring Istio or Linkerd sidecars.
globs: deploy/**/*.yaml, deploy/**/*.yml, k8s/**/*.yaml, k8s/**/*.yml, terraform/**/*.tf, charts/**/values.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-ebpf-host-routing-wireguard-mesh-invariant"
---

# Cilium eBPF Host-Routing WireGuard Mesh Invariant

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Injecting user-space sidecar proxies for mTLS encryption and leaving eBPF host-routing disabled

## System Constraints
You are a Principal Infrastructure & Network Security Architect enforcing Cilium eBPF host-routing and WireGuard mesh invariants. Mandate in-kernel transport encryption, zero-sidecar L3/L4 enforcement, bpf.masquerade, and strict cryptographic isolation across multi-tenant Kubernetes clusters. Reject configurations falling back to iptables, kube-proxy, or user-space TLS proxy sidecars.

## Strict Guidelines
- Engineers MUST ALWAYS configure Cilium with 'encryption.enabled: true' and 'encryption.type: wireguard' to enforce kernel-level transport encryption.
- Engineers MUST ALWAYS enable 'bpf.masquerade: true' and ensure 'bpf.hostRouting: true' is set to maintain direct in-kernel routing through TC (Traffic Control) BPF programs.
- Engineers MUST NOT rely on user-space service mesh sidecars (e.g., Envoy sidecars) solely for L3/L4 transport encryption when Cilium WireGuard is capable of transparent node-to-node encapsulation.
- Services MUST enforce cryptographic tenant boundary isolation via CiliumNetworkPolicy utilizing strict endpoint selectors and egress peer cryptographic verification.
- Components NEVER permit unencrypted inter-node pod traffic fallback; 'tunnelProtocol' or native routing must integrate directly with the WireGuard interface ('cilium_wg0').

## Bad vs Good Implementations
### Cilium Helm Values: Unencrypted Legacy Network Stack vs. In-Kernel WireGuard eBPF Routing

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Disables transparent encryption and forces packet transit through Linux iptables/kube-proxy routing paths. Introduces user-space context-switching overhead and permits plaintext pod-to-pod inter-node traffic across the physical underlay.
```yaml
cilium:
  encryption:
    enabled: false
  kubeProxyReplacement: "partial"
  bpf:
    masquerade: false
    hostRouting: false
  routingMode: "tunnel"
  tunnelProtocol: "vxlan"
```

#### Production Standard (Correct)
> **Standard**: Enables fully transparent in-kernel WireGuard encryption for both pod-to-pod and node-to-node egress traffic. eBPF host-routing bypasses upper network stack overhead directly via TC programs on the physical interfaces and cilium_wg0.
```yaml
cilium:
  encryption:
    enabled: true
    type: wireguard
    nodeEncryption: true
  kubeProxyReplacement: "true"
  bpf:
    masquerade: true
    hostRouting: true
  routingMode: "native"
  ipv4NativeRoutingCIDR: "10.244.0.0/16"
```

### Tenant Egress Cryptographic Isolation via CiliumNetworkPolicy

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Permits unconstrained outbound connectivity to all entities, circumventing egress cryptographic boundaries and allowing data exfiltration across unverified namespaces or external endpoints.
```yaml
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
  name: allow-all-egress
  namespace: payment-processing
spec:
  endpointSelector:
    matchLabels: {}
  egress:
    - toEntities:
        - all
```

#### Production Standard (Correct)
> **Standard**: Defines explicit egress boundaries constrained to designated peer namespaces and ports, enforced directly within eBPF maps and encapsulated within WireGuard without sidecar involvement.
```yaml
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
  name: secure-tenant-egress
  namespace: payment-processing
spec:
  endpointSelector:
    matchLabels:
      app.kubernetes.io/part-of: transaction-engine
  egress:
    - toEndpoints:
        - matchLabels:
            "k8s:io.kubernetes.pod.namespace": settlement-service
            "app.kubernetes.io/name": ledger
      toPorts:
        - ports:
            - port: "8443"
              protocol: TCP
```

Recommended MCP Servers (mcp-serverlist.com)

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

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Cilium eBPF Host-Routing WireGuard Mesh Invariant

Cilium eBPF Host-Routing WireGuard Mesh Invariant defines an industrial-grade behavioral standard for devops engineering. Enforces transparent in-kernel packet encryption via Cilium eBPF host-routing and WireGuard mesh, bypassing the Linux network stack and user-space proxy overhead. Guarantees end-to-end cryptographic isolation and strict mutual authentication across tenant namespace boundaries without requiring Istio or Linkerd sidecars. 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: Injecting user-space sidecar proxies for mTLS encryption and leaving eBPF host-routing disabled 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 DriftInjecting user-space sidecar proxies for mTLS encryption and leaving eBPF host-routing disabledCritical
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 configure Cilium with 'encryption.enabled

Engineers MUST ALWAYS configure Cilium with 'encryption.enabled: true' and 'encryption.type: wireguard' to enforce kernel-level transport encryption.

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 enable 'bpf.masquerade

Engineers MUST ALWAYS enable 'bpf.masquerade: true' and ensure 'bpf.hostRouting: true' is set to maintain direct in-kernel routing through TC (Traffic Control) BPF programs.

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 NOT rely on user-space service mesh sidecars (e.g., Envoy sidecars) solely for L3/L4 transport encryption when Cilium WireGuard is capable of transparent node-to-node encapsulation.

Engineers MUST NOT rely on user-space service mesh sidecars (e.g., Envoy sidecars) solely for L3/L4 transport encryption when Cilium WireGuard is capable of transparent node-to-node encapsulation.

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 enforce cryptographic tenant boundary isolation via CiliumNetworkPolicy utilizing strict endpoint selectors and egress peer cryptographic verification.

Services MUST enforce cryptographic tenant boundary isolation via CiliumNetworkPolicy utilizing strict endpoint selectors and egress peer cryptographic verification.

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 permit unencrypted inter-node pod traffic fallback

Components NEVER permit unencrypted inter-node pod traffic fallback; 'tunnelProtocol' or native routing must integrate directly with the WireGuard interface ('cilium_wg0').

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 Cilium eBPF Host-Routing WireGuard Mesh Invariant critical for AI coding assistants?

Enforces transparent in-kernel packet encryption via Cilium eBPF host-routing and WireGuard mesh, bypassing the Linux network stack and user-space proxy overhead. Guarantees end-to-end cryptographic isolation and strict mutual authentication across tenant namespace boundaries without requiring Istio or Linkerd sidecars. 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 (Injecting user-space sidecar proxies for mTLS encryption and leaving eBPF host-routing disabled) 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

Cilium