Skip to content

feat(proxy): Phase 3a TCP-over-mTLS floor for transparent capture - #294

Closed
bpalermo wants to merge 1 commit into
mainfrom
feat/tcp-mtls-floor
Closed

bpalermo wants to merge 1 commit into
mainfrom
feat/tcp-mtls-floor

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Summary

Implements proposal 018 Phase 3a: transparent L4 passthrough for non-HTTP services over per-source SPIRE mTLS with SPIFFE SAN pinning. HTTP/gRPC traffic continues through the HCM path unchanged.

Data-plane design

Outbound (capture listener per pod)

  • tls_inspector listener filter added alongside http_inspector (enables ALPN reading)
  • Non-HTTP services get a per-ClusterIP tcp_proxy filter chain matched on prefix_ranges: [ClusterIP/32]
  • HTTP/gRPC services have no per-IP chain — the global HCM catch-all handles them (avoids destination-IP > application-protocol precedence conflict)
  • Source proxy sets ALPN "aether-tcp" on its upstream transport socket

Inbound (:15008 per pod)

  • TCP floor chain matched on application_protocols: ["aether-tcp"] prepended before the HCM chains
  • Routes to the pod's app_<pod>_<port> cluster; terminates mTLS (SPIRE SDS)

TCP clusters

  • Separate tcp:<service>.<meshDomain> EDS clusters — no h2 protocol options, ALPN "aether-tcp" on transport socket
  • Share the same EDS load assignment as the corresponding HTTP cluster (same endpoints)
  • Built from captureTCPClusters(), emitted only when capture is enabled

Annotation flow

  • AnnotationMeshAppProtocol on generated mesh Services ("http" for all current PROTOCOL_HTTP services)
  • Reconciler classifies non-HTTP services and calls SetCaptureTCPServices
  • Cache stores cniPod in listenerEntry so per-pod capture listeners are regenerated in-place when the TCP service set changes

What is NOT changed

  • Existing HTTP/gRPC paths — zero change to HCM chains, capture route table, or outbound clusters
  • No chart changes — Phase 3a is a pure control-plane / data-plane change, no new feature flags needed beyond the existing --capture-enabled
  • ORIGINAL_DST cluster is not used — all TCP traffic routes to a proper EDS cluster with SPIFFE SAN validation

Test plan

  • TestGenerateCaptureListener — tls_inspector present, no TCP chains when no TCP services
  • TestGenerateCaptureListener_WithTCPServices — 2 TCP floor chains + HCM catch-all, correct /32 prefix matches
  • TestGenerateCaptureListener_InvalidTCPService — bad/empty ClusterIPs silently skipped
  • TestInboundTCPFloorFilterChain — ALPN match, tcp_proxy → app cluster, mTLS transport socket
  • TestNewInboundListener updated — TCP floor chain now at index 0, HCM at index 1
  • TestIsHTTPAppProtocol — all HTTP-family variants true; tcp/ws/grpc-web false
  • TestReconcile_ProjectsTCPServices — only non-headless TCP services produce entries
  • TestGenerator_AnnotatesHTTPAppProtocol — PROTOCOL_HTTP services get "http" annotation
  • TestGenerator_UpdatesStaleAppProtocol — stale annotation corrected on reconcile
  • All 24 agent + registrar tests pass (bazel test //agent/... //registrar/... --test_arg=-test.short)

DO NOT MERGE — DO NOT DEPLOY TO TALOS. This PR is for review only.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N7oY7W8oDXrqDzFgoZh25S

Implements proposal 018 Phase 3a: a TCP passthrough path alongside the existing
HTTP/gRPC HCM path for transparent capture. Non-HTTP services get per-ClusterIP
tcp_proxy floor chains on the outbound capture listener (prefix_ranges /32 match)
and the inbound :15008 listener gains an ALPN-demuxed TCP floor chain
(application_protocols: ["aether-tcp"]) so source-proxy TCP connections bypass
the HCM entirely and are forwarded directly to the pod's app cluster over SPIRE
mTLS with SPIFFE SAN pinning. HTTP services are intentionally excluded to avoid
filter-chain precedence conflicts (destination-IP > application-protocol).

- common/constants: AnnotationMeshAppProtocol annotation for registry-generated Services
- registrar/services: generator writes "http" annotation on all PROTOCOL_HTTP services
- capture/reconciler: SetCaptureTCPServices — projects non-HTTP services to the cache
- proxy/capture: tls_inspector listener filter, buildCaptureTCPFloorFilterChain,
  AetherTCPALPN constant, CaptureTCPService proxy-layer type
- proxy/ingress: buildInboundTCPFloorFilterChain (ALPN match → tcp_proxy → app cluster)
- proxy/networkfilter: buildTCPProxyNetworkFilter helper
- proxy/egress: TCPClusterName, NewTCPServiceCluster, InjectUpstreamTCPMTLS
- proxy/transportsocket: UpstreamTCPTransportSocket (ALPN "aether-tcp" override)
- proxy/transportsocketmatch: UpstreamTCPTransportSocketMatches
- cache: captureTCPClusters, SetCaptureTCPServices (with live per-pod listener rebuild),
  cniPod stored in listenerEntry for regeneration on TCP-service set changes

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01N7oY7W8oDXrqDzFgoZh25S
@bpalermo

Copy link
Copy Markdown
Owner Author

Superseded by #295 (integrated with MCS phase-1). Work preserved there.

@bpalermo bpalermo closed this Jun 24, 2026
bpalermo added a commit that referenced this pull request Jun 24, 2026
PR #294 (TCP-over-mTLS floor) and #296 (TCPRoute/TLSRoute/UDPRoute L4
routing) were both unreachable because the service model was HTTP-only: a
workload could never be classified as TCP. This lets a workload be
registered and generated as a PROTOCOL_TCP service so the capture TCP
floor and L4 routes become reachable and e2e-testable.

- proto: add Service.Protocol PROTOCOL_TCP = 2.
- registration (registry/cni.go): pick the protocol from the new
  endpoint.aether.io/protocol pod annotation (default "http"; "tcp" =>
  PROTOCOL_TCP; unknown values rejected).
- generator: project PROTOCOL_TCP services into selectorless mesh Services
  annotated aether.io/app-protocol=tcp (the agent capture reconciler's
  TCP-floor signal); one mesh Service per name, HTTP claimed first.
- registrar snapshot/sync/server: list + sync every protocol; supersede
  write-behind unregisters across protocols.
- agent watch cache (RegistrarRegistry): partition the watch-fed cache by
  protocol so ListAllEndpoints(protocol) returns only that protocol's
  services; ListAllEndpoints now gates on watch readiness (not a non-empty
  partition) so an empty protocol returns the truthful empty set.
- agent EDS (cache/cluster.go): build TCP service cluster entries holding
  the bare-name EDS load assignment (+ SAN/sni) that the floor's
  "tcp:<svc>.<domain>" cluster references; no HTTP h2 cluster/vhost is
  emitted for a TCP service.
- ghost sweep: reconcile both protocols so TCP endpoints aren't ghost-pruned.

Operator marks a workload TCP with the pod annotation:
  endpoint.aether.io/protocol: tcp

Adds unit tests: registration picks TCP from the annotation; the generator
emits a tcp-annotated mesh Service; the agent builds a tcp:<svc> cluster
with EDS endpoints. HTTP behavior is unchanged (default is HTTP).


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

Co-authored-by: Claude Opus 4.8 <[email protected]>
@bpalermo
bpalermo deleted the feat/tcp-mtls-floor branch October 11, 2026 05:18
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