homek8s/docs/pod-to-pod-encryption-decision.md
Lance Walters ddc1a5732e docs: pod-to-pod encryption decision record (WG vs mutual auth, measured)
Spike, no cluster changes. Measured: same-node pod<->pod plaintext on the
veth; cross-node already encrypted on the wire by wg0 but plaintext at the
node; Cilium 1.20.1 has WG GA and mutual auth beta+deprecated (removal
planned v1.21); nested WG costs ~7% of 1 GbE (895 -> 809 Mb/s) and pod MTU
drops 1420 -> 1325. Recommendation: no-go as a fix for same-node exposure;
conditional go with a staged rollout if a compliance case appears.
2026-12-03 02:45:39 -05:00

23 KiB
Raw Blame History

Pod-to-pod encryption: WireGuard vs mutual auth (measured)

Decision record for the question "how does pod-to-pod traffic get encrypted, and should we turn it on?" Written 2026-12-03 as a spike: no cluster changes were made, and every number below came from a read-only probe or a throwaway pod that was deleted afterwards.

Cluster at time of writing: Cilium 1.20.1 (quay.io/cilium/cilium:v1.20.1@sha256:ae9ea21…), cilium-dbg status → Encryption: Disabled, Routing: Network: Native / Host: Legacy, MTU updated (1420). Nodes: siriussec (amd64, 8 threads, control-plane+gateway+worker), rpi (arm64, 4 cores, hub), linode (amd64, 2 cores). 67 running pods: 51 on siriussec, 6 on rpi, 10 on linode.

Verdict

No-go on Cilium WireGuard as a fix for the exposure that motivated this card. Cilium's WireGuard mode does not encrypt traffic between two pods on the same node — by design, documented, and the reason is sound (the node can read it anyway). 76% of running pods are on siriussec, so the dominant pod-to-pod path in this cluster is exactly the path Cilium WG leaves in cleartext. Enabling it would add a second crypto layer, drop pod MTU to 1325, and buy a guarantee the cluster already has for the one path it does cover (cross-node traffic is already WG-encrypted by wg0, measured below).

No-go on Cilium mutual auth (SPIFFE/mTLS). In the installed chart version the feature is deprecated as of v1.20 with removal planned for v1.21 (helm values comment + cilium/cilium#47132), it is Beta, it needs a SPIRE deployment that does not exist here, and it authenticates connections — it does not encrypt them without WireGuard or IPsec beneath.

Conditional go on encryption.type=wireguard if a compliance requirement appears that says "pod traffic between hosts must be encrypted by the CNI" (today it is encrypted by the host tunnel instead). The staged plan in §6 is what that would cost; §4 says the throughput cost is ~7% and the CPU cost is affordable; §5 says the rollback is a one-commit revert plus a DaemonSet rollout.

The single biggest risk of enabling it is not the encryption: it is a false sense of security (same-node traffic is still readable at the node, and host-network/ingress traffic stays unencrypted unless the beta nodeEncryption is also enabled) plus the 95-byte MTU drop silently fragmenting anything that hardcodes 1500/1420 (the amd64 CI runner's dind bridge is hardcoded at 1420 today — §5).

1. Current exposure, measured

Four probes, each from a vantage that matters. Test pods (nicolaka/netshoot:v0.13) were created in a throwaway encspike namespace — two on siriussec, one each on rpi/linode — and the namespace was deleted at the end (kubectl get pods -A | grep -c iperf = 0).

# Path Vantage Command Result
1 same-node pod→pod receiver pod's veth on the node sudo tcpdump -n -A -i lxc<peer> 'tcp port 9000' while curl http://10.244.0.45:9000/secret.txt Plaintext: GET /secret.txt HTTP/1.1, Host:, User-Agent:, HTTP/1.0 200 OK, body marker readable
2 cross-node pod→pod LAN wire sudo tcpdump -n -A -i enp0s31f6 'udp port 51820' during the same curl to a pod on rpi Opaque: only UDP, length 1452 WG datagrams; grep -c SPIKE = 0, grep -c "GET " = 0
3 cross-node pod→pod node, after decapsulation sudo tcpdump -n -A -i wg0 'host 10.244.1.182 and tcp' Plaintext again: GET /secret.txt HTTP/1.1, HTTP/1.0 200 OK
4 pod→API node loopback sudo tcpdump -n -i lo 'tcp port 6443' while curl -k https://10.10.0.2:6443/version Cilium BPF rewrites it to 127.0.0.1:<port> → 127.0.0.1:6443; TLS content, L4 metadata visible
5 unrelated pod sniffing another pair inside a pod with NET_RAW tcpdump -i eth0 -c 5 'tcp port 5201' during srv-siriussec → srv-linode iperf3 (632 Mbit/s) 0 packets captured — pods have no L2 adjacency (ip neigh shows only cilium_host), so an unprivileged pod cannot sniff its neighbours

What this means, precisely:

  • Same-node pod↔pod is plaintext and is readable by anything in the host network namespace — every host process, and therefore any pod with hostNetwork: true or privileged: true. It is not sniffable by another ordinary pod (probe 5).
  • Cross-node pod↔pod is encrypted on the wire today (probe 2) by the host wg0, but decrypted at the destination node (probe 3), so the node vantage still reads it.
  • Pod→API never leaves the node and is TLS-protected by Kubernetes itself; CNI encryption would add nothing to its content and would not even see it (same-node).
  • Traffic to node addresses is not CNI-encryptable by default: registry (10.10.0.1:5000), Garage S3 (10.10.0.1:3900), kubelet, and the host-network Envoy ingress path (node → pod) are not covered by encryption.type=wireguard unless the beta encryption.nodeEncryption/--encrypt-node is enabled. Cilium's own coverage table (docs, v1.20 "Which traffic is encrypted") says exactly this: Pod→remote Pod = default mode; Pod→remote Node, Node→remote Pod, Node→remote Node, and Client outside cluster→pod via Service under native routing = node-to-node mode only.

So the unencrypted set is: same-node pod↔pod (51/67 pods), host↔pod, pod↔node-address, and anything with a compromised host netns. The card's premise ("two pods on siriussec speak plaintext across the bridge") is confirmed — with the correction that there is no bridge: pods are /32 on lxc* veths and are routed through cilium_host (probe 1's capture shows the veth, not a bridge).

2. WireGuard mode vs mutual authentication — capability of the installed build

Read from the running agent and the shipped chart, not from blog posts:

kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg status | grep -E 'Encryption|Cilium:|Routing'
  Cilium:      Ok   1.20.1 (v1.20.1-7d68cfb3)
  Routing:     Network: Native   Host: Legacy
  Encryption:  Disabled
kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-agent --help | grep -E 'enable-wireguard|encrypt-node|mesh-auth'
  --enable-wireguard            Enable WireGuard
  --encrypt-node                Enables encrypting traffic from non-Cilium pods and host networking (only supported with WireGuard, beta)
  --mesh-auth-mutual-listener-port int   Port on which the Cilium Agent will perform mutual authentication handshakes between other Agents
kubectl get ciliumnodes -o json | jq '.items[] | {name:.metadata.name, wg:.metadata.annotations["network.cilium.io/wg-pub-key"], enc:.spec.encryption}'
  linode    wg-pub-key: null  encryption: {}
  rpi       wg-pub-key: null  encryption: {}
  siriussec wg-pub-key: null  encryption: {}
ip link show cilium_wg0        # on siriussec
  Device "cilium_wg0" does not exist.

Support status in v1.20.1, from the pinned docs and chart of that version:

Mode Status here Evidence
encryption.type=wireguard GA/stable (encryption.enabled + type are ordinary chart values; only nodeEncryption and encryption.strictMode.* are marked beta) install/kubernetes/cilium/values.yaml @ v1.20.1; agent flag --enable-wireguard; docs page "WireGuard Transparent Encryption" carries no beta banner
encryption.nodeEncryption / --encrypt-node beta agent --help text; docs section "Node-to-Node Encryption (beta)"
Mutual auth (authentication.mutual.spire) beta + deprecated; removal planned v1.21 chart comment: "Deprecated as of Cilium v1.20, this feature will be removed in Cilium v1.21"; cilium/cilium#47132 (open, 2026-07-13); no cilium-spire namespace or SPIRE pods in this cluster
CNP authentication.mode: required CRD field exists (authentication present in ciliumnetworkpolicies.cilium.io schema, mode enum includes required), but policy enforcement is only meaningful with authentication.enabled/SPIRE; 6 CNPs exist today, none use it kubectl get crd ciliumnetworkpolicies.cilium.io -o json; kubectl get cnp -A
encryption.type=ztunnel (Istio ztunnel, the mTLS-shaped option) beta, new in 1.20, CA internal or spire, own DaemonSet + 200m/512Mi per node chart encryption.ztunnel block; agent flag --enable-ztunnel

Comparison on the axes that decide this:

Axis Cilium WG Mutual auth (SPIFFE/SPIRE) ztunnel
What it closes Reads of cross-node pod traffic on the wire (already closed by wg0). Not same-node, not host↔pod, not pod↔node unless nodeEncryption (beta). Authentication of L4 connections by source identity, per CNP rule; encryption only as a side effect of WG/IPsec underneath mTLS between pods via per-node proxy, identity from SPIFFE
Key distribution Per-node keypair generated by the agent, written to its state dir (cilium_wg0.key), published in the network.cilium.io/wg-pub-key annotation on CiliumNode; peers read it from the API SPIRE server issues SVIDs; SPIRE stack must be deployed and maintained CA (internal or SPIRE) issues workload certs
Rotation No operator-facing interval; a new keypair is generated when the agent's key file is missing (node reboot / state loss) and every peer re-reads the annotation. No PSK, no post-quantum: Rosenpass covers wg0 only, cilium_wg0 is a separate classical-X25519 tunnel — the PQ work from t_fb8bc782 does not extend to it SVID rotation by SPIRE (short TTLs) cert rotation by CA
CPU Measured §3: 2nd layer ≈ +0 CPU observably at 1 GbE; the T480 carries ~1.4 cores for 1 Gbit/s of double-sided crypto in the same kernel + handshake/agent per connection; SPIRE server + agent pods + proxy hop per connection (200m/512Mi per node before any traffic)
MTU pod MTU 1420 → 1325 (WireguardOverhead = 95 in pkg/mtu/mtu.go @ v1.20.1); measured 60-byte IPv4 per-packet cost and the 95-byte worst case inherits WG/IPsec MTU proxy MTU accounting, plus 1 extra user-space hop
Debugging cilium-dbg status, cilium-dbg debuginfo | jq .encryption, tcpdump -i cilium_wg0; a LAN capture now shows only UDP/51871 so "is the app broken or the tunnel" costs a hop failed auth is a policy verdict (Hubble shows it) — a different, noisier failure surface ztunnel logs/metrics, new component to learn
Failure modes Documented known issue: packets can be dropped while the WG device is reconfigured on endpoint add/remove → connection resets during pod churn; MTU mis-sizing fragments (measured, §3); a node whose key is stale/unpublished silently falls back to plaintext SPIRE outage breaks new connections cluster-wide; policy mistakes deny traffic rather than encrypt it beta maturity, single proxy per node is a new SPOF
Node reboot keypair regenerated, republished; peers converge when annotations propagate — a window of plaintext/unreachable per node SVID re-attestation per node; SPIRE datastore is the recovery dependency cert re-issue

3. The nesting problem — measured

Node transport is already WireGuard (wg0, MTU 1420). Cilium's cilium_wg0 would ride inside it on every cross-node path, so each pod packet is encrypted twice.

All runs: iperf3 -t 10 -O 2, MTU 1420 pod path, siriussec → rpi (1 LAN hop) unless noted.

Run Shape P1 P4 Notes
T1 same-node pod→pod (baseline, no tunnel) 16.2 Gb/s 40.3 Gb/s loopback; 1 GbE is not involved
T2 cross-node, host wg0 only (current production) 895 Mb/s 896 Mb/s link-bound (1 GbE); T480 CPU 17%→25% peak, Pi 1% avg / 5% peak
T3 cross-node 2 host hops (siriussec→Pi→linode) 787 Mb/s 743 Mb/s Pi forwards (decrypt+encrypt) and still sits at ~1–5%
T4 nested: pod-WG device MTU 1420 over the 1420 path 536 Mb/s 525 Mb/s every outer packet fragmented (flags [+], first fragment 1420 B of a 1480 B datagram); no P-scaling
T5 one pod-WG layer, same node, MTU 1360 (correctly sized) 1.06 Gb/s 1.04 Gb/s double-sided crypto in one kernel — not the production shape
T6 nested: pod-WG MTU 1360 over host wg0, cross-node (production shape) 809 Mb/s 831 Mb/s 7–9% below T2; both layers' counters incremented; Pi 1% avg / 5% peak

Commands (T6; the rest are the same shape):

# in the server pod: create a WG device and serve on it
ip link add wgout type wireguard
ip addr add 10.98.0.1/24 dev wgout
wg set wgout listen-port 51999 private-key /tmp/wg/priv \
   peer <client-pub> allowed-ips 10.98.0.2/32 endpoint 10.244.0.134:51999 persistent-keepalive 5
ip link set mtu 1360 up dev wgout
iperf3 -s -B 10.98.0.1 -p 5202

# in the client pod: peer it to the pod on rpi, so its outer packets ride host wg0
wg set wgout peer <rpi-pod-pub> allowed-ips 10.98.0.1/32 endpoint 10.244.1.182:51999
iperf3 -c 10.98.0.1 -p 5202 -t 10 -O 2 -P1

# CPU: 1 s /proc/stat sampler on both nodes while it runs
ssh siriussec 'bash /tmp/cpusamp2.sh 24'     # per-core util, prints agg%/maxcore%

Reading: the second layer costs ~7% throughput at 1 GbE — the link is the ceiling, not the crypto — but it doubles the crypto work on the two endpoint nodes and the Pi stays cheap because it only carries one layer. Nothing here argues against WG on performance grounds. The fragmentation row (T4) is the cautionary one: an inner device at 1420 on a 1420 path does not fail loudly, it halves throughput.

4. MTU fallout

  • Today: pod MTU 1420, because Cilium derives it from the route MTU of wg0 (cilium-dbg status --verbose → job-mtu-updater [OK] MTU updated (1420); verified in three pods with cat /sys/class/net/eth0/mtu).
  • With encryption.type=wireguard, v1.20.1 subtracts WireguardOverhead = 95 (pkg/mtu/mtu.go), and the agent sets cilium_wg0 MTU to deviceMTU - 95 (pkg/wireguard/agent/agent.go). So pod MTU becomes 1325 and max inner payload 1297. Measured check of the arithmetic: one tunnel layer at MTU 1360 accepted ping -M do -s 1332 and dropped -s 1333 (60 B WG + 28 B ICMP); the outer datagram for a 1392-byte payload was 1452 B of UDP (1480 B on the wire) and arrived fragmented.
  • Workloads that must be checked after such a change (all currently at 1420 or 1500):
Workload Why Check
ci-runners/forgejo-runner-amd64 (dind) dockerd --mtu=1420 is hardcoded in the Deployment args; containers inside dind would be 95 B over the pod path set dind MTU to the new pod MTU (1325) and re-run an android/rust job; docker network inspect MTU
Forgejo CI → registry 10.10.0.1:5000 node address, not encrypted by WG without nodeEncryption; unchanged MTU either way, but a "pod traffic is encrypted now" assumption is wrong here curl -I http://10.10.0.1:5000/v2/ inside a pod
CNPG pg (forgejo, metabase, customer1) single instance each, all on siriussec → same-node, unaffected; replication (if a replica is ever added) would be cross-node psql -c 'show max_wal_senders'; kubectl cnpg status after
Cilium native routing (autoDirectNodeRoutes) the MTU updater will rewrite existing endpoint MTUs, but established TCP sessions keep their old MSS restart/reconnect workloads; ss -ti on a pod
coredns (on siriussec, used by pods on rpi/linode) DNS is cross-node → newly encrypted; small packets, low risk dig @10.96.0.10 kubernetes.default from a pod on rpi
host-network Envoy gateway node → pod ingress is not encrypted without the beta nodeEncryption; MTU unchanged curl -H 'Host: <site>' http://10.10.0.2:8080/ after
Loki/Alloy, Prometheus scraping same-node, unaffected kubectl -n logging logs ds/alloy --tail=20
osint pipeline (nats, titiler, app) same-node; only its S3/Garage (10.10.0.1:3900) and outbound egress are node/LAN paths check ingest watermark after

5. Rollback (and why it is cheap)

Cilium is a Flux HelmRelease (kube-system/cilium, chart 1.20.1, values rendered from infrastructure/networking/cilium/values.yaml into ConfigMap cilium-values-66dk8gtmt9). Rollback is a git revert, not a CLI dance:

# 1. revert the value in git (encryption.enabled: false / drop encryption.type)
git revert --no-edit <enable-commit> && git push forgejo master
# 2. make Flux act now instead of waiting for the poll
kubectl -n flux-system annotate gitrepository flux-system reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite
kubectl -n flux-system annotate kustomization infrastructure reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite
# 3. watch the agents roll and confirm the device is gone
kubectl -n kube-system rollout status ds/cilium --timeout=10m
kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg status | grep Encryption   # -> Disabled
ip link show cilium_wg0                                                                        # -> does not exist

Stop-the-bleeding while git lags (Flux force: false for infrastructure, so a live patch survives until the next revision — close the drift afterwards):

kubectl -n flux-system patch kustomization infrastructure --type merge -p '{"spec":{"suspend":true}}'
kubectl -n kube-system patch cm cilium-config --type merge -p '{"data":{"enable-wireguard":"false"}}'
kubectl -n kube-system rollout restart ds/cilium
# then revert the commit in git and resume the Kustomization

Recovery time: one agent restart per node is ~10–30 s; the whole DaemonSet is expected to settle in 1–3 minutes, after which pod networking is plaintext wg0-only again (the state we are in today, which is known-good). Not measured — measuring it needs the rollout, which this spike did not perform.

Per-node staged enable: no at the config level, yes in effect. All agents read one ConfigMap/DS arg, so the switch is cluster-wide; but WireGuard is opportunistic per peer — a node that has not restarted has no wg-pub-key annotation, so traffic to it stays plaintext instead of breaking. That makes a chunked DaemonSet rollout (maxUnavailable) a safe staged enable: no mixed-mode outage, only a temporary mixed-encryption window. That is the behaviour the docs imply and the design of UpdatePeer; it is not verified here.

6. Staged rollout plan (if the compliance case appears)

Pre-checks, in this order, all currently failing/pending:

  1. Firewall: UDP 51871 is closed. Pi ufw default-deny with per-port allows only (ufw status verbose → Default: deny (incoming); 36 ALLOW rules, none for 51871), same on linode. Nothing is bound on 51871 anywhere yet (ss -lnu | grep 51871 → 0). Required: ufw allow from 10.10.0.0/24 to any port 51871 proto udp on rpi and linode (Cilium peers over node InternalIPs, i.e. the mesh), and the same source class on siriussec if its nft table grows a default-deny policy.
  2. MTU decision first, not after: set the dind runner's dockerd --mtu to 1325 in the same commit, or its builds will fragment.
  3. Pin Cilium version in the HelmRelease (already pinned at 1.20.1) and record cilium-dbg status as the before-state.
  4. Enable encryption.enabled: true + encryption.type: wireguard in infrastructure/networking/cilium/values.yaml; do not enable nodeEncryption in the first pass (beta, and it changes the ingress path).
  5. Push, annotate gitrepository + kustomization infrastructure, watch kubectl -n kube-system rollout status ds/cilium node by node; after each node verify: cilium-dbg status | grep Encryption → Wireguard [cilium_wg0 … Peers: 2], cilium-dbg debuginfo | jq .encryption, ip -d link show cilium_wg0 (MTU 1325), pod eth0 MTU 1325, ping -M do -s 1297 OK / -s 1298 FAIL, and a cross-node iperf3 ≥ 800 Mb/s.
  6. Regression matrix: every public hostname (curl -H 'Host: …' http://10.10.0.2:8080/), Grafana :8081 / Hubble :8084 / Metabase :8085 / customer1 :8086,:8087 by bare IP, a registry pull into a test pod, one Forgejo CI job, kubectl get nodes Ready, coredns from a pod on rpi.
  7. Keep the rollback commit ready (§5) and expect it, because the documented known issue is packet loss while the WG device is reconfigured on endpoint churn — i.e. during exactly the Flux-driven rollouts that happen several times a week.

7. Blast radius

Every public hostname and the API terminate on siriussec (Envoy is hostNetwork, label gateway=true, API 10.10.0.2:6443). 51 of 67 running pods live there:

Namespace Pods Public/internal surface
sirius-growth 6 3 public hostnames + contact API
siriusdevops, piedmont 2+2 public sites + contact APIs
forgejo (+ pg) 2 forgejo.siriusdevops.com, CI runners' registry
monitoring 7 Grafana :8081, Alertmanager → Telegram, Prometheus
metabase, customer1 2+3 :8085, :8086, :8087
osint 3 osint site
flux-system, cert-manager, cnpg-system, logging, netsec, node-io, local-path, ci-runners 12 platform plumbing

A pod-networking fault during the change takes all of that down at once. The mitigating fact: enabling WG only touches cross-node paths, and same-node pod↔pod keeps working, so the failure would surface as "coredns/pods on rpi+linode can't reach siriussec" rather than "everything 503s". The registry pulls and the siriussec ↔ rpi/linode control traffic are the canaries.

8. Explicitly not verified

  • Cilium WG throughput/CPU on this cluster — that needs the change; §3 numbers are a pod-level WG device nested inside wg0, i.e. the same packet shape, not the Cilium code path.
  • DaemonSet rollout time and the mixed-encryption window.
  • Whether any listed workload actually breaks at MTU 1325 (dind is the one that definitely needs the change; the rest are reasoned, not exercised).
  • nodeEncryption (beta) with the hostNetwork Envoy gateway — untested; the ingress node → pod path therefore remains unencrypted in every plan here.
  • Key-rotation-after-reboot behaviour: read from source (pkg/wireguard/agent/agent.go writes cilium_wg0.key if absent), not exercised on a node.
  • ztunnel (encryption.type=ztunnel) — not deployed, not tested; it is the only future mTLS-shaped option in this CNI and it is beta.
  • The wg0/Rosenpass PQ layer was not touched; it applies to wg0 only and would not cover cilium_wg0.
  • The documented WG known issue (packet drops during device reconfiguration) was not reproduced; the linked GitHub issue (#33159) is closed and unrelated.

Appendix — probe inventory

Everything below was created and deleted inside this spike (encspike namespace, 4 nicolaka/netshoot:v0.13 pods, apk add wireguard-tools, two pod-local WG devices on port 51999). Final state check: kubectl get pods -A | grep -c iperf = 0, kubectl get all,ns -A | grep -c encspike = 0. No Cilium/HelmRelease/WireGuard/Rosenpass object was modified.