JOIN A SERVE TO A HUB
This guide joins a swamp serve to a hub as a member, so the hub can see it.
Note
Preview. Serve federation is a preview feature: no flag turns it on, and its commands and the serve-hub app may change in later releases. Every serve and every CLI that uses it must run Swamp 20261129.160739.0 or later.
Prerequisites
- A hub, and a join token minted on it for this member's name. See Set Up a Serve Federation Hub.
- The hub's URL:
https://, orhttp://only tolocalhost,127.0.0.0/8or[::1]. It may carry a path prefix, but no credentials, query or fragment. - The member reaches the hub over outbound HTTPS. The hub never connects to the member.
Save the token
On the member host, in the repository, save the token to a file only you can read:
(umask 077; cat > join-token.txt)Paste the token, then press Ctrl-D. Keep the file out of version control.
Run swamp serve hub join
swamp serve hub join https://hub.example.com --token-file join-token.txthub join writes the federation block for you. It never reads the token,
never contacts the hub and never starts serve. What it does depends on the
serve.yaml the repository has.
No serve.yaml
It writes a minimal version 2 member file:
✓ Wrote /srv/swamp/edge-1/.swamp/serve.yaml to join http://localhost:19600 with the join token in join-token.txt.
Start (or restart) serve to join: federation is read only at startup. Then run swamp serve hub to watch the join.version: 2
federation:
hub: "http://localhost:19600"
join-token-file: "join-token.txt"A version 1 file
It moves the file to version 2 first. If version 2 would refuse a key, it writes nothing and names the key:
Error: Joining a hub needs serve.yaml version 2, which would refuse max-concurent-runs (did you mean max-concurrent-runs?). Fix or remove them (swamp serve check-config lists them), then run join again.Fix the key, as in
Move serve.yaml to Version 2,
and run hub join again. It stamps version: 2, adds the block and keeps every
other line:
version: 2
port: 19602
max-concurrent-runs: 4
federation:
hub: "http://localhost:19600"
join-token-file: "join-token.txt"A version 2 file
It adds the block:
✓ Updated /srv/swamp/edge-2/.swamp/serve.yaml to join http://localhost:19600 with the join token in join-token.txt.
Start (or restart) serve to join: federation is read only at startup. Then run swamp serve hub to watch the join.A file that is already a hub or a member
It refuses and names the way to move:
Error: serve.yaml already has a federation block: this serve is a hub, or belongs to one. To move it to another hub, remove the member on its current hub (swamp serve member remove), stop serve, run swamp serve hub forget --yes, and delete the federation block, then join again.A relative --token-file resolves against the current directory, and is written
relative to the repository when it lies inside it. With --json, hub join
prints { configPath, defaultConfig, fromVersion, hubUrl, tokenFile }, where
fromVersion is "none", 1 or 2.
If serve starts with --config <path>, pass the same --config to hub join,
and keep starting serve with it.
Start serve and watch the join
Start, or restart, serve. It joins in the background; serve's readiness, runs and workers never wait for the hub. The serve log records:
Joined hub "central" as member "edge-1"Check the link on the member:
swamp serve hubHub: http://localhost:19600 (central)
State: joined
Member: edge-1 e581dcbd-c776-4510-af87-e3aa77687d5e
Joined: 2026-11-29T23:49:45.161Z
Instances:
c0163988-5359-4f0e-942e-1e8f655be449 ok, last check-in 2026-11-29T23:49:45.175ZThe state moves from unjoined to joining to joined. The member then checks
in every 30 seconds. On the hub, swamp serve member list shows it online.
Join a serve on Kubernetes
Run swamp serve hub join against the source file the ConfigMap's serve.yaml
is built from, with --config, so the command writes the federation block and
moves a version 1 file to version 2. Keep the token in a Secret mounted as a
file under the repository path, at the path you pass to --token-file;
hub join checks that the file exists but never reads it, so an empty file at
that path is enough when you run the command:
mkdir -p federation && touch federation/join-token
swamp serve hub join https://hub.example.com \
--token-file federation/join-token --config deploy/serve.yamlJoin a serve federation hub in the Kubernetes guide has the full steps: the Secret, the volume mount, and the rollout. The member's credential lives in the datastore's encrypted control-plane vault, so a replaced Pod on the same datastore is the same member.
Join several nodes of one member
Serves that share one datastore, in team mode or a multi-instance deployment,
are one member with several instances. Give every node the same serve.yaml and
token file. One node joins; each node then checks in on its own, and
swamp serve member get lists every instance. A member records at most 64 live
instances.
Troubleshooting
Run swamp serve hub on the member. It shows the link state and each instance's
last result. The serve log names the same cause.
unjoined, with no instances
No instance has tried to join yet. If serve.yaml names a join-token-file,
swamp serve hub says to start serve:
Not joined yet: serve.yaml names a join-token-file. Start (or restart) serve to join, as federation is read only at startup; a running serve's log says why it has not joined.Start serve. If serve.yaml names no join-token-file, the hint says to set
one:
Not joined: set federation.join-token-file in serve.yaml to a token minted on the hub, then restart serve.Run swamp serve hub join with a token minted on the hub, then start serve.
Before Swamp 20261130.004414.0, swamp serve hub shows this second hint in both
cases.
joining does not become joined
The member cannot reach the hub: the URL is wrong, the hub is down, or TLS
fails. The instance result is unreachable or server_error, and the member
retries with backoff up to 5 minutes. Check the URL in serve.yaml, that the
hub answers on it from the member host, and that the member trusts the hub's
certificate (serve's --ca-cert adds roots).
join_refused
The token was used, expired, revoked or never minted. swamp serve hub shows:
The hub refused the join token (used, expired, revoked or unknown). Mint a new one, set it as the join-token-file, then restart serve.The serve log says:
The hub refused the join token (used, expired, revoked or unknown). Mint a new one and restart serveMint a new token on the hub, write it to the token file and restart serve. A
member the hub removed shows the refused hint instead, since its
link is refused, not unjoined; the fix is the same.
name_taken
Another serve is a live member with this name. swamp serve hub shows:
The hub refused the join: a live member already has this name. Remove it on the hub, or set a join-token-file minted for another name, then restart serve.The serve log says:
The hub refused the join: a live member already has this name. Remove it on the hub, then restart serveMint a token for a different name and write it to the token file, or remove the other member on the hub first, then restart serve.
refused
The hub removed this serve or revoked its credential; set a new join-token-file and restart serve to join again.The member was removed on the hub, or its credential was lost. Check-ins stop until restart. To rejoin, see Rejoin after removal.
mismatched
serve.yaml names a different hub from the one this serve joined. Restore the
original hub URL to resume, or move the member to the new hub as in
Move a member to another hub.
rate_limited
The hub is limiting requests from this address. The member backs off and
retries, honouring the hub's retry-after. No action is needed unless it
persists.
instance_limit
The member already has 64 live instances. An instance is dropped once it stops checking in, and pruned after 24 hours unseen.
Related
- Manage Serve Federation Members
- Serve Federation reference — link states, instance results and error codes
- Serve Federation explanation