Skip to content

feat: add TCP advertise address support for cross-cluster deployments#2

Merged
fergusfinn merged 2 commits into
mainfrom
feat/tcp-advertise-address
Apr 9, 2026
Merged

feat: add TCP advertise address support for cross-cluster deployments#2
fergusfinn merged 2 commits into
mainfrom
feat/tcp-advertise-address

Conversation

@fergusfinn
Copy link
Copy Markdown

Summary

Adds support for separating bind and advertise addresses on the TCP response and request plane servers. This is needed for multi-cluster dynamo deployments where the frontend pod IP is not directly routable by remote workers.

Problem

In a cross-cluster setup (e.g., frontend on GKE, workers on bare-metal MicroK8s connected via Tailscale/VPN), the frontend's response TCP server auto-detects its pod IP and embeds it in connection_info sent to workers. Workers then try to connect back to that pod IP, which isn't routable from outside the cluster.

Solution

New environment variables allow the advertise address to differ from the bind address:

Response TCP server:

  • DYN_TCP_RESP_HOST — bind host override
  • DYN_TCP_RESP_PORT — bind port override
  • DYN_TCP_RESP_ADVERTISE_HOST — what gets sent to workers in connection_info
  • DYN_TCP_RESP_ADVERTISE_PORT — advertise port (e.g., NodePort)

Request plane TCP:

  • DYN_TCP_RPC_ADVERTISE_HOST — overrides host in etcd registration
  • DYN_TCP_RPC_ADVERTISE_PORT — overrides port in etcd registration

When advertise vars are unset, behavior is unchanged (bind address = advertise address).

Example usage

Frontend exposed via a Kubernetes NodePort on port 30100:

DYN_TCP_RESP_ADVERTISE_HOST=frontend.example.com
DYN_TCP_RESP_ADVERTISE_PORT=30100

Workers connect to frontend.example.com:30100, which routes to the frontend pod's actual TCP port.

Test plan

  • Build frontend image with this patch
  • Deploy with DYN_TCP_RESP_ADVERTISE_HOST set to a routable address
  • Verify workers receive the advertise address in connection_info
  • Verify responses flow back through the advertised endpoint
  • Verify default behavior (no env vars set) is unchanged

Add support for separating bind and advertise addresses on both the
request plane and response plane TCP servers. This enables deployments
where the frontend pod IP is not directly routable by workers (e.g.,
multi-cluster setups with NAT or VPN).

New environment variables:

Response TCP server (TcpStreamServer):
- DYN_TCP_RESP_HOST: bind host override (default: auto-detect)
- DYN_TCP_RESP_PORT: bind port override (default: OS-assigned)
- DYN_TCP_RESP_ADVERTISE_HOST: advertise host override (default: bind host)
- DYN_TCP_RESP_ADVERTISE_PORT: advertise port override (default: bind port)

Request plane TCP (endpoint registration):
- DYN_TCP_RPC_ADVERTISE_HOST: advertise host override (default: DYN_TCP_RPC_HOST)
- DYN_TCP_RPC_ADVERTISE_PORT: advertise port override (default: DYN_TCP_RPC_PORT)

When advertise vars are set, the server binds locally as usual but
communicates the advertise address to peers via connection_info and
etcd registration. This allows exposing the TCP ports via a NodePort,
LoadBalancer, or VPN endpoint without changing how the server binds.
@github-actions github-actions Bot added the feat label Apr 9, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 34147ea983

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/runtime/src/component/endpoint.rs
Comment thread lib/runtime/src/distributed.rs Outdated
Reject port 0 from DYN_TCP_RPC_ADVERTISE_PORT and
DYN_TCP_RESP_ADVERTISE_PORT so templated configs that default to 0
fall through to the actual bound port instead of publishing
an unconnectable address.
@fergusfinn fergusfinn merged commit 8558660 into main Apr 9, 2026
9 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant