Files
coder/docs/admin/networking
Andrew G. Dunn c11d60ad8d docs: note the pubsub cluster port between HA replicas (#30290)
HA replicas connect to each other's embedded NATS pubsub on TCP 6222.
The port is hardcoded
([`coderd/x/nats/pubsub.go`](https://github.com/coder/coder/blob/7f3d35353eddcd8a9e573094e5e2531bd2d73659/coderd/x/nats/pubsub.go#L62))
with no flag or environment variable, and since #29283 NATS pubsub is on
by default. The HA page explains `CODER_CLUSTER_HOST` but doesn't name
the port, so a firewall or default-deny NetworkPolicy between `coderd`
nodes blocks it. This adds the port, and what happens without it, next
to `CODER_CLUSTER_HOST`.

Measured on v2.37.3 (`CODER_EXPERIMENTS=nats_pubsub`, the default on
main) with two replicas on GKE under a default-deny NetworkPolicy, port
8080 open between the replicas in both runs. Through a port-forward to
replica B, `PUT /api/v2/workspaces/{id}/extend` publishes a workspace
update in the request path. A watcher on `/api/v2/workspaces/{id}/watch`
through replica A counts the events. The control sends the same request
through A.

6222 blocked:

```text
label=blocked A=coder-699ccb59f8-695bj B=coder-699ccb59f8-w8glp baseline_data_events=1
control: extend via A -> HTTP 409; data events on A: 1 (expect 1)
test: 5x extend via B -> HTTP 409 409 409 409 409; data events on A: 0
coder-699ccb59f8-695bj :6222 established: 0
coder-699ccb59f8-w8glp :6222 established: 0
```

6222 allowed between the replicas (same pods, no restart):

```text
label=allowed A=coder-699ccb59f8-695bj B=coder-699ccb59f8-w8glp baseline_data_events=1
control: extend via A -> HTTP 409; data events on A: 1 (expect 1)
test: 5x extend via B -> HTTP 409 409 409 409 409; data events on A: 5
coder-699ccb59f8-695bj :6222 established: 4
coder-699ccb59f8-w8glp :6222 established: 4
```

The 409s are expected because the workspace is stopped; the handler
publishes the update before it returns
([`coderd/workspaces.go`](https://github.com/coder/coder/blob/3a248167f6e58462a8a8cddba3b49a8ff72a9f80/coderd/workspaces.go#L1711)
at v2.37.3).

Would it also make sense for the chart to declare 6222 as a container
port, or for the port to be configurable? I left both out of this
change.

AI involvement: I used an AI assistant to draft this change, and
verified it with the runs above against a two-replica deployment.
2026-10-07 19:21:29 -04:00
..