Skip to content

docs(proposal): multi-protocol ports on one mesh service (037) - #881

Merged
bpalermo merged 4 commits into
mainfrom
docs/037-multi-protocol-per-service
Sep 21, 2026
Merged

bpalermo merged 4 commits into
mainfrom
docs/037-multi-protocol-per-service

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Draft proposal — for review, not for acceptance. No code changes; one new file.

Renders at docs/proposals/037_multi-protocol-per-service.md.

What it is

A mesh workload is classified HTTP or TCP for the whole pod, and by extension the whole service. The invariant is stated once in agent/internal/xds/cache/cluster.go:202 and encoded in six other places (both cluster passes' shared map key, the registrar's protocol-partitioned cache and write-behind, the mesh-Service generator, RequireProtocolDisjoint, and the kubernetes backend's return nil for TCP). A pod serving an HTTP API on :8080 and a raw-TCP protocol on :9000 cannot say so.

Splitting into two Services is not an escape: the mesh Service is generated per <ns>/<serviceAccount>, so "two Services" means two ServiceAccounts means two pods, with every identity-keyed policy duplicated.

The finding that reframes it

The constraint is not the c.clusters[serviceName] collision.

The TCP floor's mesh hop carries no SNI and no ALPN — InjectUpstreamTCPMTLS(cl, …, "") at capture.go:344, deliberately: #306 established that a non-empty SNI would land on the destination's per-port HCM chain, and #304 removed the bespoke aether-tcp ALPN. So the destination has exactly one default floor chain, and it forwards to the pod's primary port with no input from the caller.

Fixing the map key alone therefore yields "HTTP ports plus one TCP port (the primary)", not a service with several TCP ports.

Almost none of the rest is an Envoy limitation. Envoy evaluates destination_port ahead of prefix_ranges, and the capture listener already sets use_original_dst, so a per-port capture chain is a one-field addition to a match that already exists — and it dissolves the "/32 outranks the HCM catch-all" conflict that forces the invariant today.

What it proposes

A port has a protocol; a service has ports — the shape L7 already has since 005.

Extend the existing endpoint.aether.io/ports suffix grammar ("8080,9090=h2") with =tcp, and keep endpoint.aether.io/protocol as the default for unsuffixed ports, so every current manifest means exactly what it meant. A pure-TCP service is byte-for-byte unchanged.

Also: map<uint32, Service.Protocol> port_protocols = 12 on ServiceEndpoint (edition 2023, additive), dual registration under the existing keys rather than changing any key layout, per-port tcp:<fqdn>:<p> clusters with SNI=<port>, and matching in_tcp_<pod>_<p> inbound chains so an HCM chain and a TCP chain never share server_names.

Phasing

Phase 0 is #878 on the existing invariant and ships independently — podToEndpoint honours protocol, and populates Ports. That second half is a separate finding this turned up: the kubernetes backend has never read endpoint.aether.io/ports either, so Ports is nil on every endpoint it returns and 005's per-port EDS membership has never worked on the chart default backend.

Phases 1–3 are cache keying, per-port protocol, then port-qualified L4 routes.

Review focus

  • The resolution rule table — every client spelling → (port, protocol). Everything else serves it.
  • Risk 4, listener drain on capture regeneration: moving classification into the cache means a new regeneration trigger, and it must be edge-triggered on the derived map or endpoint churn drains per-pod listeners.
  • Open question 1, GAMMA: ProjectHTTPRule resolves backendRef.port without knowing the port's protocol, and it also runs in the registrar's config-export controller where there are no endpoints. Needs a call.

Each risk states what would make its gate fail, with negative controls; the two process gates are labelled as such rather than dressed as data-plane ones (#853).

Related: #878 (Phase 0), #877 (adjacent — design (d) closes its source half structurally, but the fix shouldn't wait), #868/#879 (the L4 harness the kind e2e extends).

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

bpalermo and others added 2 commits September 20, 2026 16:51
A mesh workload is classified HTTP or TCP for the whole pod, and by
extension the whole service: "A service is HTTP or TCP, never both, so the
two sets never share a name" (cache/cluster.go:202). A pod serving an HTTP
API on :8080 and a raw-TCP protocol on :9000 cannot say so, and the mesh
Service is generated per ServiceAccount, so splitting is not an option the
user has.

Draft only -- no code changes, nothing accepted.

The constraint is not the map key. The TCP floor's mesh hop carries no SNI
and no ALPN (deliberately -- #304, #306), so the destination has exactly one
default floor chain and it forwards to the pod's primary port. Fixing the
c.clusters collision alone yields "HTTP ports plus one TCP port", not
multi-TCP-port.

Proposes the per-port model -- a port has a protocol, a service has ports --
by extending the existing endpoint.aether.io/ports suffix grammar with
"=tcp", keeping endpoint.aether.io/protocol as the per-port default so every
current manifest keeps its meaning. Capture chains gain destination_port,
which Envoy evaluates ahead of prefix_ranges and which resolves the
"/32 outranks the HCM catch-all" conflict that forces the invariant today.

Phased so the fix that does not need any of it ships first: Phase 0 is #878
alone (podToEndpoint honours protocol, and populates Ports -- the kubernetes
backend has never carried 005's per-port EDS membership either), on the
existing invariant.

Each risk states what would make its gate fail, with negative controls, and
the two process gates are labelled as such rather than dressed as data-plane
ones (#853).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Revision from the PR #881 review. The first draft resolved the bare name to
"the primary port, in the primary's protocol", which re-introduced the
asymmetry the proposal exists to remove.

- Add ProxyTCPOutboundPort = 18082 beside 18081 (free tree-wide; the only
  hits are an arbitrary test argument in l4route_test.go). 18081 is HTTP,
  18082 is TCP, for every service.
- A portless URL resolves by its scheme's default port: http:// is 80 and
  HTTP by definition, https:// is 443 and TCP iff the app registered it.
  Raw TCP names its port because it has no scheme. HTTP demuxes on the
  authority header; TCP demuxes on the 5-tuple - that distinction is now
  the justification for the scheme, not a wart.
- http://svc/ needs NO new config: the HCM chain has no destination-port
  criterion and RDS matches the portless authority today. Documented
  intent only. A destination_port:80 chain is listed as rejected.
- http:// to a service with no HTTP port: 421 direct_response vhost with
  x-aether-error, replacing today's unnamed cluster_not_found 503.
- https:// to a mesh service: option (a) refuse deterministically via a
  name-only 443 Service port (kube-proxy REJECT); (b) terminating app TLS
  at the capture listener is scoped out as its own proposal.
- The portless /32 floor chain and its special cases collapse into one
  uniform destination_port chain; :18082 works under scoped capture (CNI
  rule extended), per-app-port TCP still needs redirect-all (two tiers).
- Generated mesh Services expose 18081, 18082 and name-only 80/443, and
  the generator must converge Spec.Ports (it converges annotations only
  today; the MCS clusterset VIP create is create-only).
- New Risk 9: registrar advertises :18082 before a node's agent can serve
  it -> ECONNREFUSED within one RTT, gated by a negative-control e2e.
- "Require a port from every caller" recorded under Alternatives.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo and others added 2 commits September 21, 2026 08:51
Phase 0 landed as #888: the kubernetes backend honours
endpoint.aether.io/protocol and populates Ports. Two deviations from the
proposal text, both found in the writing, are recorded in place:

  - the shared parser landed as a leaf package //registry/endpointmeta rather
    than a registry.PortProtocols helper, because //registry/internal/k8s
    importing its parent interface package is the wrong direction;
  - the health-check-mode parser was deliberately NOT shared -- the two
    backends disagree on the UNSET case (EDS vs UNSPECIFIED) and unifying them
    would have silently flipped the CNI registration path.

Also records that only e2e/uds.sh runs on the chart-default kubernetes
backend; every other suite, l4routes.sh included, forces etcd, which is #878's
complaint in harness form.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit 16af7aa into main Sep 21, 2026
22 checks passed
@bpalermo
bpalermo deleted the docs/037-multi-protocol-per-service branch September 21, 2026 11:56
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