Skip to content

feat(mesh): add the TCP mesh port 18082 (037 Phase 2, Release A) - #890

Merged
bpalermo merged 1 commit into
mainfrom
feat/037-phase2a-tcp-mesh-port
Sep 21, 2026
Merged

bpalermo merged 1 commit into
mainfrom
feat/037-phase2a-tcp-mesh-port

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Proposal 037 Phase 2, Release A — the control-plane half. Follows #889 (Phase 1). Deliberately inert on its own.

What ships

  • ProxyTCPOutboundPort = 18082 — the mesh's well-known TCP spelling, the L4 counterpart of ProxyOutboundPort. Verified free tree-wide (in-use 18xxx: 18001, 18008, 18009, 18021, 18054, 18080, 18081).
  • Four ports on every generated mesh Service — mesh 18081, mesh-tcp 18082, and name-only http 80 / https 443. These Services are selectorless and hold no endpoints, so kube-proxy REJECTs an unclaimed port: an uncaptured https://<svc>/ fails with ECONNREFUSED instead of hanging in a CNI-dependent way.
  • The scoped CNI rule redirects dport 18082 alongside 18081. This is what makes :18082 work without redirect-all, unlike a dial to a service's own application port. UDP is deliberately not redirected for 18082 — it's a TCP spelling, and the UDP floor addresses backends by application port.

Why a second port at all

HTTP demuxes on the authority header, which carries its own port as a string — so http://<svc>/ is unambiguous without one. Raw TCP has no authority; its only demux key is the 5-tuple. Without a well-known TCP port, the bare name's meaning would depend on whichever protocol the service's primary port happened to be, so a client's spelling would change meaning when a service was re-annotated. That was the asymmetry this proposal exists to remove.

A migration gap found while writing this

The generator's apply path compared annotations alone and returned early, never touching Spec.Ports. A mesh Service created before this change would have kept its single mesh port forever — the new spellings would have appeared only on a fresh install, which is the worst way to discover a missing migration. Ports now converge, compared order-insensitively so an API-server reorder isn't treated as drift (#135 is the same mechanism on the route table).

Interim safety

Between Release A and B the CNI redirects 18082 but no agent chain matches destination_port 18082 yet. A redirected connection falls to the capture listener's passthrough, reaches the mesh-tcp Service port, and is REJECTed by kube-proxy — immediate ECONNREFUSED, not a hang and not a silent blackhole.

Negative controls

  • Dropping the Spec.Ports convergence fails TestGenerator_ConvergesPortsOnExistingService against a pre-037 single-port Service.
  • The CNI test asserts the encoded dport (0x46a2), not merely that a rule exists — a rule built for the wrong port installs cleanly, captures nothing, and looks identical to a working one. It caught a wrong constant in its own first draft.

bazel build //... clean, 56 tests pass, lint clean. No charts/ changes, so no Chart.yaml bump.

Two Release A items deliberately NOT here

port-protocols annotation. It needs per-port data that arrives with the proto field in Release B. Stamping a primary-port-only form now would advertise a feature that doesn't work yet.

The =tcp webhook guard. The proposal calls for the pod-mutating webhook to reject =tcp until the agent supports it. Two problems worth deciding before building it:

  1. There is no pod validating webhook. The controller's /validate dispatches by Kind (MeshConfig, HTTPFilter, EdgeConfig, EndpointPolicy, HTTPRoute); pods only have the /mutate path. Rejecting from a mutating webhook works but is an odd shape.
  2. It needs to know the agent version, and the only non-drifting mechanism is a chart value set by the same chart release that ships the agent. That works — chart is the unit of deployment — but within a single helm upgrade the controller rolls before the agents, so a =tcp pod created in that few-minute window still registers as HTTP on an old agent's node.

Given the guard can't fully close the window it exists for, the alternative is to drop it and rely on the documented skew rule (roll the agent before annotating) plus a loud WARN from the new agent when it sees =tcp. That trades a silent downgrade for a documented ordering constraint. I'd rather decide that explicitly than build a gate that can't quite fail.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Release A of proposal 037 Phase 2: the control-plane half that makes
<svc>.<ns>.<mesh-domain>:18082 addressable and safe to dial BEFORE the agent
can serve it. Deliberately inert on its own.

  - ProxyTCPOutboundPort = 18082, the mesh's well-known TCP spelling and the
    L4 counterpart of ProxyOutboundPort. Free tree-wide when chosen (in-use
    18xxx: 18001, 18008, 18009, 18021, 18054, 18080, 18081).
  - The generated mesh Service exposes four ports: "mesh" 18081, "mesh-tcp"
    18082, and name-only "http" 80 / "https" 443. The Services are
    selectorless and hold no endpoints, so kube-proxy REJECTs an unclaimed
    port -- an uncaptured scheme-default dial fails with ECONNREFUSED instead
    of hanging in a CNI-dependent way.
  - The scoped CNI rule redirects dport 18082 alongside 18081. This is what
    makes :18082 work WITHOUT redirect-all, unlike a dial to a service's own
    application port. UDP is deliberately NOT redirected for 18082: it is a
    TCP spelling, and the UDP floor addresses backends by application port.

Why a second port rather than resolving the bare name by the service's
protocol: HTTP demuxes on the authority header, which carries its own port as
a string, so `http://<svc>/` is unambiguous without one. Raw TCP has no
authority -- its only demux key is the 5-tuple -- so it needs a port, and
without a well-known one the bare name's meaning would depend on whichever
protocol the service's PRIMARY port happened to be. A client's spelling would
change meaning when a service was re-annotated.

Also fixes a migration gap found while writing this: the generator's apply
path compared ANNOTATIONS alone and returned early, never touching
Spec.Ports. A mesh Service created before this change would have kept its
single "mesh" port forever, so the new spellings would have appeared only on a
fresh install -- the worst way to discover a missing migration. Ports now
converge, compared order-insensitively so an API-server reorder is not drift.

Interim safety, between Release A and B: the CNI redirects 18082 but no agent
chain matches destination_port 18082 yet, so a redirected connection falls to
the capture listener's passthrough, reaches the "mesh-tcp" Service port, and
is REJECTed by kube-proxy. Immediate ECONNREFUSED, not a hang or a silent
blackhole.

Negative control: dropping the Spec.Ports convergence fails
TestGenerator_ConvergesPortsOnExistingService with the pre-037 single-port
Service. The CNI test asserts the ENCODED dport (0x46a2) rather than merely
that a rule exists -- a rule built for the wrong port installs cleanly,
captures nothing, and looks identical to a working one. It caught a wrong
constant in its own first draft.

Not included, and why: the `port-protocols` annotation needs per-port data
that arrives with the proto field in Release B, so stamping a primary-port-only
form now would advertise a feature that does not work yet. The `=tcp` webhook
guard needs a mechanism this repo does not have -- see the PR.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit 8e2a13b into main Sep 21, 2026
22 checks passed
@bpalermo
bpalermo deleted the feat/037-phase2a-tcp-mesh-port branch September 21, 2026 14:11
bpalermo added a commit that referenced this pull request Sep 21, 2026
…#891)

The guard was specified as "the pod-mutating webhook rejects =tcp until the
chart's agent version supports it". It cannot do that job:

  - there is no pod VALIDATING webhook (the controller's /validate dispatches
    by Kind; pods reach only /mutate), and
  - it must know the agent version, whose only non-drifting source is a chart
    value set by the same release that ships the agent -- but within one helm
    upgrade the controller rolls BEFORE the agents, so a pod annotated in that
    window still registers as HTTP on an old agent's node.

It narrows the window it exists for without closing it, and a gate that cannot
fail in the case it was built for is decoration (#853). Replaced by the
documented skew rule plus a loud WARN from the new agent, and the condition
that would reopen the decision is stated.

Also records Release A as shipped (#890), including the two items that moved:
the port-protocols annotation defers to Release B where its data exists, and
the Spec.Ports migration gap that Release A had to fix.


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

Co-authored-by: Claude Opus 5 <[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