Skip to content

feat(agent): replace HBONE tunnel with plain per-source mTLS transport - #98

Merged
bpalermo merged 4 commits into
mainfrom
feat/plain-mtls-transport
Jun 9, 2026
Merged

bpalermo merged 4 commits into
mainfrom
feat/plain-mtls-transport

Conversation

@bpalermo

@bpalermo bpalermo commented Jun 9, 2026 •

Copy link
Copy Markdown
Owner

What

Removes the HBONE / HTTP-2 CONNECT tunnel data path and replaces it with plain per-source-pod mTLS HTTP/2, with a per-pod inbound listener (R1's inbound structure) reached directly at pod_ip:15008.

Why

Ambient/HBONE alignment isn't required and Aether is HTTP-only, so CONNECT bought nothing we needed while costing the entire internal-listener / filter-state demux apparatus (the source of most R2 incidents). Tradeoff, accepted: we lose node-level connection multiplexing — the source holds ~one mTLS connection per dest pod (R1-like) — for a much smaller, more debuggable data plane. Spike-validated.

Inbound is per-pod, not per-node, which is the natural fit once the tunnel is gone:

  • Lifecycle — the listener is added/removed with the pod (CNI ADD/DEL), so Envoy drains it gracefully with the pod instead of just dropping a route.
  • Network policy — bound to the pod's netns, so pod-scoped NetworkPolicy/CNI rules apply to its mesh inbound.
  • Identity — presents the pod's own SVID as the server cert, so callers verify they reached the right pod, not just the node.

How

Egress (proxy/egress.go): NewServiceCluster — EDS, HTTP/2, connection_pool_per_downstream_connection, lb subset by ip; per-source mTLS matcher (netns → cert) injected at snapshot time (InjectUpstreamMTLS). Endpoints target pod_ip:15008 directly.

Ingress (proxy/ingress.go): NewInboundListener — a per-pod listener on 0.0.0.0:15008 in the pod's netns, mTLS-terminate (pod SVID), XFCC native (SANITIZE_SET), catch-all → app_<pod>.

Cache: service clusters get the mTLS matcher injected per snapshot; listenerEntry carries the inbound listener again; the node-level node_inbound/tunnel_*/inner_* resources are gone.

app_<pod>/health_<pod> clusters and delegated liveness are unchanged.

Tests / scope

  • bazel test //agent/... green; make format + --config=lint clean. Net −496 lines vs main.
  • Follow-up PR removes the now-unused internal_listener bootstrap extension from charts/agent (and node_ip is now unused for routing — candidate cleanup).
  • E2E on talos-main next. Rollback = redeploy prior (R2) agent image.

🤖 Generated with Claude Code

bpalermo and others added 4 commits June 8, 2026 21:18
Remove the HBONE / HTTP-2 CONNECT tunnel data path and replace it with plain
per-source-pod mTLS HTTP/2 node-to-node, demuxed natively by request authority.
Ambient/HBONE alignment is not a requirement and Aether is HTTP-only, so CONNECT
bought nothing we needed while costing the whole internal-listener/filter-state
demux apparatus. (Tradeoff, accepted: we lose node-level connection multiplexing —
the source now holds ~one mTLS connection per dest pod, like the R1 model — for a
much smaller, more debuggable data plane. Spike-validated.)

Egress (proxy/egress.go, was tunnel.go):
- NewServiceCluster: EDS, HTTP/2, connection_pool_per_downstream_connection, lb
  subset by ip. The per-source mTLS transport-socket matcher is injected at snapshot
  time (InjectUpstreamMTLS) from the current local workloads.
- ServiceLocalityLbEndpointFromRegistryEndpoint: endpoint address = dest node
  (node_ip:15008), hostname = dest pod IP.
- Outbound route sets auto_host_rewrite so :authority becomes the selected endpoint
  hostname (the dest pod IP) — the native demux discriminator.

Ingress (proxy/ingress.go, was connectlistener.go):
- NewNodeInboundListener: single mTLS listener on :15008, HTTP/2, forward XFCC
  natively (SANITIZE_SET from the verified peer), route by :authority vhost
  (pod IP) -> app_<pod>. node-live via the health_check filter. No internal
  listeners, no inner_demux, no filter-state capture, no XFCC rebuild.

Cache: service clusters get the mTLS matcher injected per snapshot
(clustersEndpointsAndVhosts); snapshot emits the single node_inbound listener in
place of node_connect + tunnel_internal + tunnel_originate + the per-pod inner set.

Deleted: tunnel_internal, tunnel_originate, inner_<pod>, inner_demux_<pod>,
internal_upstream, peer.uri capture, XFCC reconstruction, buildInboundRouteConfiguration.
app_<pod>/health_<pod> clusters and delegated liveness are unchanged.

Net -417 lines. Follow-up PR removes the now-unused internal_listener bootstrap
extension from charts/agent. E2E on talos-main next.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Make the mesh inbound a per-pod listener bound into the pod's network namespace
(R1's inbound structure) rather than a single node-level listener demuxing by
:authority. Per-pod is the natural fit once the HBONE tunnel is gone and is also
simpler:

- Lifecycle: the listener is added/removed with the pod (CNI ADD/DEL), so Envoy
  drains it gracefully with the pod instead of just dropping a route.
- Network policy: bound to the pod's netns, so pod-scoped NetworkPolicy/CNI rules
  apply to its mesh inbound.
- Identity: presents the pod's OWN SVID as the server cert, so callers verify they
  reached the right pod, not just the node.

Ingress (proxy/ingress.go): NewInboundListener builds a per-pod listener on
0.0.0.0:15008 in the pod netns, mTLS-terminate (pod SVID), XFCC native
(SANITIZE_SET), catch-all -> app_<pod>. Drops the node_inbound listener, the
:authority vhost demux, and the health_check node-live filter (pod liveness is the
EDS health pipeline; a down node fails to connect).

Egress (proxy/egress.go): service cluster endpoints target pod_ip:15008 directly;
drops the endpoint hostname, node_ip dependency, and auto_host_rewrite.

GenerateListenersFromRegistryPod again returns the inbound listener (per pod);
listenerEntry/Listeners()/AddPod/LoadListenersFromStorage carry it. Net -496 vs main.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…nbound listener

Add two envoy.filters.http.health_check filters (non-pass-through) to each pod's
inbound listener, before the router:

- Liveness (/-/-/live): flat 200. Reaching it proves the proxy config is loaded and
  the listener is serving; because the listener requires mTLS, a success also proves
  mTLS termination is up. No application dependency, so it stays green while the app
  is (re)starting.
- Readiness (/-/-/ready): 200 only when, in addition, the pod's app health-probe
  cluster (health_<pod>, which actively HCs the app's readiness path) is healthy via
  cluster_min_healthy_percentages{health_<pod>: 100}; otherwise 503.

Everything else passes through to app_<pod>. Validated with envoy v1.38: two
health_check filters coexist (distinct names, factory resolved from typed_config),
/live = 200 always, /ready = 503 when health_<pod> is /failed_active_hc and 200 when
healthy.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Add an active HTTP health check to the outbound service cluster against each
endpoint's mesh readiness path (/-/-/ready) over the cluster's mTLS. The HC
connection carries no source filter state, so the per-source transport-socket
matcher's on-no-match presents the node identity (the intended node-driven probe).
A 200 means the destination pod is ready (config + mTLS up and the app passes its
readiness probe); a 503 or connection failure drops the endpoint from load
balancing. ignore_new_hosts_until_first_hc keeps traffic off a newly discovered pod
until its first readiness check passes.

Spike-validated on envoy v1.38: the client HC connects over mTLS via on-no-match and
marks the endpoint healthy when /ready=200 and /failed_active_hc when /ready=503.

Note: this makes the delegated-liveness EDS health_status pipeline (agent scrape ->
registry health -> EDS) redundant for routing; candidate for removal in a follow-up
(the health_<pod> cluster stays — it feeds the inbound readiness filter).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@bpalermo
bpalermo merged commit 2ad41b2 into main Jun 9, 2026
10 checks passed
@bpalermo
bpalermo deleted the feat/plain-mtls-transport branch June 9, 2026 01:07
bpalermo added a commit that referenced this pull request Jun 9, 2026
…eld (#102)

The HBONE tunnel and per-node CONNECT listener were removed in #98/#101,
but several comments in the xDS cache and SPIRE bridge still described the
node SPIFFE ID as the CONNECT listener's server cert / node-to-node tunnel
identity. Update them to its actual current role: the no-match upstream
client cert presented by outbound clusters for node-originated connections
(e.g. active health-check probes) plus the node-health listener.

Also drop listenerEntry.pod, which was only retained to rebuild the removed
CONNECT listener's per-pod routes; it is now written but never read. Removing
it makes the cni/v1 import in cache.go unused.

Co-authored-by: Claude Opus 4.8 <[email protected]>
bpalermo added a commit that referenced this pull request Jun 11, 2026
…y memory

Three related hardenings from the 2026-06-11 worker-04 incident (a proxy DS
roll cost a ~165s node data-plane gap):

1. Bind-collision retry. When the predecessor proxy's heartbeat goes stale
   (its LIVE-gated writes stop whenever its admin probes time out under
   node load) but its Envoy is still alive, initStartEpoch picks epoch 0
   and the fresh Envoy loses the base-id domain-socket bind race
   (errno 98), exiting within milliseconds. The supervisor previously
   exited non-zero, handing the retry to the kubelet's CrashLoopBackOff —
   whose 10..80s gaps, stacked against the predecessor draining out its
   180s termination grace in awaitProtocolTermination, produced the
   outage. A newest epoch that dies non-LIVE within 5s of launch in
   cross-pod mode is now retried in-process every 3s: epoch detection is
   re-run from scratch (attach at E+1 if the predecessor becomes
   confirmable, epoch 0 once the socket frees), the predecessor keeps
   serving throughout, and the first attempt after it exits binds with at
   most a 3s gap. Bounded at 90 attempts so a genuinely broken Envoy
   (bad bootstrap also dies fast) still surfaces as a pod crash. New
   child-exit metric kind: bind_collision_retry.

2. Proxy resources. The proxy container had no requests or limits at all:
   the connection-leak incident grew Envoy to 3.5 GiB and degraded the
   NODE (kubelet flap, agent informer desync) rather than being contained.
   Default now requests 500m/1Gi with a 1Gi memory limit (OOM kill is
   recoverable via hot restart; node starvation is not) and deliberately
   no CPU limit (throttling the data plane converts contention into
   latency and failed health checks).

3. Netns filter state sharing narrowed TRANSITIVE -> ONCE. The transport
   is single-hop since #98 removed the HBONE tunnel; ONCE scopes the
   source-pod netns to exactly the hop where the service cluster's
   transport-socket matcher selects the client certificate, so a future
   chained/internal hop cannot silently inherit per-source cert selection.

Also documents the client-side connection-shape guidance in
workload-requirements.md: per-downstream-connection pooling makes
keepalive/HTTP-2 clients cheap (multiplexed streams share one upstream
mTLS connection) and connection-per-request the expensive shape.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
bpalermo added a commit that referenced this pull request Jun 11, 2026
…y memory (#137)

Three related hardenings from the 2026-06-11 worker-04 incident (a proxy DS
roll cost a ~165s node data-plane gap):

1. Bind-collision retry. When the predecessor proxy's heartbeat goes stale
   (its LIVE-gated writes stop whenever its admin probes time out under
   node load) but its Envoy is still alive, initStartEpoch picks epoch 0
   and the fresh Envoy loses the base-id domain-socket bind race
   (errno 98), exiting within milliseconds. The supervisor previously
   exited non-zero, handing the retry to the kubelet's CrashLoopBackOff —
   whose 10..80s gaps, stacked against the predecessor draining out its
   180s termination grace in awaitProtocolTermination, produced the
   outage. A newest epoch that dies non-LIVE within 5s of launch in
   cross-pod mode is now retried in-process every 3s: epoch detection is
   re-run from scratch (attach at E+1 if the predecessor becomes
   confirmable, epoch 0 once the socket frees), the predecessor keeps
   serving throughout, and the first attempt after it exits binds with at
   most a 3s gap. Bounded at 90 attempts so a genuinely broken Envoy
   (bad bootstrap also dies fast) still surfaces as a pod crash. New
   child-exit metric kind: bind_collision_retry.

2. Proxy resources. The proxy container had no requests or limits at all:
   the connection-leak incident grew Envoy to 3.5 GiB and degraded the
   NODE (kubelet flap, agent informer desync) rather than being contained.
   Default now requests 500m/1Gi with a 1Gi memory limit (OOM kill is
   recoverable via hot restart; node starvation is not) and deliberately
   no CPU limit (throttling the data plane converts contention into
   latency and failed health checks).

3. Netns filter state sharing narrowed TRANSITIVE -> ONCE. The transport
   is single-hop since #98 removed the HBONE tunnel; ONCE scopes the
   source-pod netns to exactly the hop where the service cluster's
   transport-socket matcher selects the client certificate, so a future
   chained/internal hop cannot silently inherit per-source cert selection.

Also documents the client-side connection-shape guidance in
workload-requirements.md: per-downstream-connection pooling makes
keepalive/HTTP-2 clients cheap (multiplexed streams share one upstream
mTLS connection) and connection-per-request the expensive shape.

Co-authored-by: Claude Opus 4.8 <[email protected]>
bpalermo added a commit that referenced this pull request Jun 19, 2026
…ss control plane (#236)

Add `agent edge`, a subtractive control-plane mode for an edge (north-south
ingress) proxy that dials mesh pods directly over mTLS — no node proxy/DaemonSet
in the path. The transport migration (#98-#101) already made node egress a plain
per-source mTLS HTTP/2 client to pod_ip:15008, so the edge is the same path with
a single identity instead of many; the node data plane is unchanged.

- `runEdge`: controller-runtime manager hosting only the xDS server + registry
  refresher (no CNI server, no per-pod storage, no SPIRE bridge). Shared
  identity/registrar/SPIRE flags extracted into registerSharedFlags so the node
  path is untouched.
- Envoy fetches its single SVID + trust bundle straight from SPIRE over a static
  spire_agent gRPC SDS cluster (config.SDSConfigSourceFromCluster +
  proxy.EdgeUpstreamTransportSocket), not the agent's ADS stream. SAN pinning is
  preserved (inline matchers over the SDS bundle).
- Edge data plane: BuildEdgeListener (0.0.0.0:8080, RDS, readiness filter ahead
  of the router), BuildEdgeRouteConfiguration (exposed vhosts + 404 catch-all, no
  ODCDS), and NewServiceCluster gains a perDownstreamConnectionPool flag so the
  single-identity edge multiplexes upstream connections.
- Snapshot cache edge mode: SetEdgeMode/SetEdgeIdentity/SetStaticDependencies;
  the static dependency set scopes the registrar watch to exactly the exposed
  services. Exposure is seeded from --expose for now; an EdgeRoute CRD watch
  replaces it in a follow-up.

Unit tests cover the edge transport socket, listener, route config, SDS config
source, static dependency seam, and edge-mode listener composition.


Claude-Session: https://claude.ai/code/session_01Pihqn5RmVPhV9HTdBnqbvY

Co-authored-by: Claude Opus 4.8 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant