---
title: "opod join"
description: "Join a machine to a cluster as a worker, with a token or a certificate, pinned to one GPU and a memory budget if needed; what it does and how it fails."
url: "https://opod.io/docs/core-cli/join/"
markdown_url: "https://opod.io/docs/core-cli/join.md"
section: "Core CLI"
last_updated: "2026-10-30"
---

# opod join

> Join a machine to a cluster as a worker, with a token or a certificate, pinned to one GPU and a memory budget if needed; what it does and how it fails.

## In short

`opod join` makes this machine a worker of a leader. It registers, heartbeats every 5 seconds, runs the leader's calls against the local engine, and stays in the foreground until you stop it. A node token in the URL (or in `OPOD_JOIN_TOKEN`) or a client certificate identifies it.

```bash
opod join "http://leader:8080?token=sk-orc-<node-token>"
```

```text
✔ joining cluster at http://leader:8080 as n_abc123
```

## Usage

```text
opod join "LEADER_URL[?token=TOKEN]" [--gpu INDEX] [--vram-budget GB]
```

`opod join` makes this machine a **worker**: it registers with a leader, serves the leader's calls on its own API, drives the local engine, and heartbeats until it is stopped. It runs in the foreground. Stop it with Ctrl-C or `SIGTERM`.

```bash
opod join "http://leader.local:8080?token=sk-orc-<node-token>"
opod join "https://opod.example.com?token=sk-orc-<node-token>"
opod join "http://leader:8080?token=sk-orc-<node-token>" --gpu 1 --vram-budget 20
OPOD_JOIN_TOKEN=sk-orc-<node-token> opod join https://opod.example.com
```

Quote the URL: `?` is a glob character in zsh. A URL without a scheme gets `http://`. A trailing `/` is removed.

## Arguments and flags

| Argument           | Default                | Effect                                                                                                                                                                                                                               |
| ------------------ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `LEADER_URL`       | — (required)           | The leader's base URL. The query `?token=` is the join token; the whole query is dropped from the URL the worker stores and dials.                                                                                                   |
| `--gpu INDEX`      | `$OPOD_GPU_INDEX`      | Pin the worker's engine to one device. The engine processes see `CUDA_VISIBLE_DEVICES=INDEX`, `HIP_VISIBLE_DEVICES=INDEX` and `ONEAPI_DEVICE_SELECTOR=level_zero:INDEX`, each unless you already set it, and `OPOD_GPU_INDEX=INDEX`. |
| `--vram-budget GB` | `$OPOD_VRAM_BUDGET_GB` | Cap the engine's GPU memory, a whole number of GB, so several workers can share one card. The engines see `OPOD_VRAM_BUDGET_GB`. For vLLM it becomes `--gpu-memory-utilization` (below).                                             |

A flag wins over its environment variable. The flags must come **after** the URL. Any other argument is refused (from core v0.4.6 the flags may also come before the URL and take `--gpu=1`, and each of these is a usage error, exit `2`):

| Error                                                                                         | Cause                             |
| --------------------------------------------------------------------------------------------- | --------------------------------- |
| ``opod: usage: opod join "<leader-url>?token=<token>"  (run `opod join --help` for details)`` | No URL.                           |
| `opod: --gpu needs a device index`                                                            | `--gpu` is the last word.         |
| `opod: --vram-budget needs a size in GB`                                                      | `--vram-budget` is the last word. |
| `opod: --vram-budget must be an integer number of GB, got "20.5"`                             | Not a whole number.               |
| ``opod: unknown join argument "--foo" (see `opod join --help`)``                              | Anything else.                    |

These variables only reach the **engine processes the worker starts** (vLLM, SGLang, llama.cpp, rpc-server). An engine you started yourself, such as an Ollama service, does not see them; pin that engine yourself.

### How a budget becomes an engine setting

For vLLM, the worker computes `--gpu-memory-utilization` at launch:

```text
utilization = (budget_GB × 1024 − overhead_MiB) / card_MiB      clamped to 0.05 … 0.95, two decimals
```

- `card_MiB` is `OPOD_CARD_MIB` when the manager set it, else what `nvidia-smi` reports for the first card. With neither (AMD and Intel hosts have no `nvidia-smi`), **the budget is not applied** and vLLM uses `0.85`.
- `overhead_MiB` is `OPOD_ENGINE_OVERHEAD_MIB` when set, else core's measured figure for the engine (its largest one for a vendor not measured).
- With no budget, vLLM gets `0.85`.

SGLang gets `--mem-fraction-static` by the same formula only when a budget is set, with a 768 MiB overhead; with no budget the flag is left out and SGLang sizes its own pool.

## Credentials

The worker presents, in this order:

1. the URL's `?token=`;
2. else `OPOD_JOIN_TOKEN`, or `auth.join_token` in this machine's `config.yaml`;
3. else its client certificate, `OPOD_NODE_CERT` and `OPOD_NODE_KEY`.

With none of them, it exits:

```text
opod: no join token (?token= in the URL, or OPOD_JOIN_TOKEN) and no worker certificate (OPOD_NODE_CERT/OPOD_NODE_KEY): one or the other identifies this worker
```

Mint a token on the leader with `opod token create --node`.

A token in the URL is visible to anyone who can list processes. A container image or a service unit should pass it in `OPOD_JOIN_TOKEN` and leave the URL bare. Joining a leader that is not `localhost`, `127.0.0.1` or `::1` over `http` with a token prints, on stderr:

```text
⚠ joining leader.local over cleartext http — the join token will be sent unencrypted; prefer https for non-local leaders
```

The token has a second job: the worker hands it to the leader at register, and the leader signs every call back into the worker with it (HMAC, see [Worker API](https://opod.io/docs/core-reference/worker-api/#authentication)). A worker that joins with a **certificate only** mints its own random secret for that job (`sk-orc-cb-…`, 32 random bytes) and sends it over the mTLS-protected register. No operator handles it.

For a TLS leader, set `OPOD_LEADER_CA` to the PEM certificate the worker must trust. The worker then trusts exactly that certificate. With `OPOD_NODE_CERT` and `OPOD_NODE_KEY`, it also presents its own client certificate; its SPIFFE SAN `spiffe://<domain>/opod/node/<id>` is the worker's identity to a leader that runs node mTLS. The leader's policy (`off`, `allow`, `require`) comes from its [auth snapshot](https://opod.io/docs/core-reference/auth-snapshot/).

**Binding.** The first `node` key that registers a node id owns it. Another `node` key that presents the same id is refused, so one leaked node token cannot impersonate every worker. A worker that registered with a certificate is bound to that certificate.

## Identity and address

- **Node id:** `OPOD_NODE_ID`, else the `node_id` in `~/.opod/node.yaml` from an earlier run, else `n_<POD_NAME>`, else a new random `n_` plus 8 characters. Keep it stable: a new id per restart leaves a `lost` row behind on the leader each time.
- **Address:** the IP of the interface that routes to the internet (found with a UDP dial that sends nothing), port `8081`. When that fails, the first non-loopback interface. `OPOD_ADVERTISE_ADDR=host:port` overrides it, for containers, overlay networks and hosts with several interfaces. When detection fails entirely, it warns and uses `0.0.0.0:8081`.
- **`~/.opod/node.yaml`** (mode `0600`) records `node_id`, `leader_url`, `token`, `address` and `joined_at`. Only `node_id` is read back, by the next `opod join`. The file holds the token: protect it. From core v0.4.6 it no longer records the token.

> **The address is also the bind address**
>
> The worker's API **listens** on the same `host:port` it advertises, and its gang processes (llama.cpp `rpc-server`, the `llama-server` coordinator) bind the same host. So `OPOD_ADVERTISE_ADDR` must be an address this machine owns, unless you also set `OPOD_BIND_ADDR`. An address that only exists on the far side of a NAT or a load balancer makes the worker fail to start its API, with `worker server exited` in the log.

### Behind NAT or a port forward

From core v0.4.0, `OPOD_BIND_ADDR` names the address this machine owns. The worker listens there, and the leader binds the worker's llama.cpp gang processes (`rpc-server`, the coordinator) there, while it keeps dialling the advertised address.

```bash
# The leader dials 203.0.113.7:18081, which the router forwards to 10.0.0.5:8081.
OPOD_ADVERTISE_ADDR=203.0.113.7:18081 OPOD_BIND_ADDR=10.0.0.5:8081 \
  opod join "http://leader:8080?token=sk-orc-<node-token>"
```

- `OPOD_BIND_ADDR=host` with no port takes the advertised port.
- Unset = the advertised address, as before.
- `0.0.0.0` is taken only when you set it, and the worker warns: llama.cpp's `rpc-server` has no authentication, so a wildcard opens it on every interface. Firewall its ports.
- Forward the gang ports too: `rpc-server` and the coordinator listen on ports the leader picks for each gang.
- **Check it worked:** the join log reads `listening on OPOD_BIND_ADDR; the leader dials the advertised address`, and `opod node show <id>` carries `"BindHost"` in its `HardwareJSON`. SGLang's rendezvous and Ray's `--node-ip-address` still take the advertised host.

## Engine

The worker drives the engine named by `engine.preferred` / `OPOD_ENGINE` (default `ollama`), at the endpoint from its own config or `OPOD_<ENGINE>_ENDPOINT`:

```bash
OPOD_ENGINE=vllm OPOD_VLLM_ENDPOINT=http://127.0.0.1:8000 opod join "http://leader:8080?token=sk-orc-<node-token>"
```

For vLLM, SGLang, llama.cpp and TensorRT-LLM the worker **starts the engine itself** when the leader asks it to load a model (`POST /v1/model/load`), and stops it at shutdown. For Ollama and MLX-LM, the engine must already run. See [Engines](https://opod.io/docs/core-reference/engines/).

`OPOD_LOAD_MODEL=<catalog id>` makes the worker load that model by itself once its engine answers, with no call from the leader. `OPOD_LOAD_REPO` and `OPOD_LOAD_FILE` override the catalog's repo and file for that load. The model's pinned revision and digest come from `OPOD_MODEL_REVISION` and `OPOD_MODEL_SHA256`; gated repos need `HF_TOKEN`, and `HF_ENDPOINT` points at a mirror.

Other worker-only variables — `OPOD_ENGINE_FLAGS`, `OPOD_ADAPTERS`, `OPOD_REJECT_BEARER`, `OPOD_DRAIN_SECONDS`, `OPOD_WORKER_ROLE`, `OPOD_KV_TIER`, `OPOD_KV_EVENTS`, `OPOD_SLEEP_MODE`, `OPOD_PLAN_REVISION`, `OPOD_ACCELERATOR`, `OPOD_CARD_MIB`, `OPOD_ENGINE_OVERHEAD_MIB` — are described in [Environment variables](https://opod.io/docs/core-reference/environment/#process-contract-worker). Three of them are checked at start and refuse a value the worker would not understand:

| Error                                                                  | Fix                               |
| ---------------------------------------------------------------------- | --------------------------------- |
| `opod: OPOD_WORKER_ROLE "x": use prefill or decode, or leave it unset` | Unset it for a whole worker.      |
| `opod: OPOD_KV_TIER "x": use cpu or peer, or leave it unset`           | Unset it for VRAM only.           |
| `opod: OPOD_DRAIN_SECONDS="x": want whole seconds from 0 to 3600`      | A whole number, at most one hour. |

Valid values look like this:

```bash
OPOD_WORKER_ROLE=decode OPOD_KV_TIER=peer OPOD_DRAIN_SECONDS=120 \
  opod join "http://leader:8080?token=sk-orc-<node-token>"
```

`OPOD_PLAN_REVISION` that is not a positive number only warns: `OPOD_PLAN_REVISION "x" is not a positive number — this worker joins the unversioned group`.

When the catalog cannot be read, the worker still starts, with `catalog unreadable (…) — vLLM and SGLang start with no tool-call parser`.

## What happens

1. Reads `config.yaml` and the environment, then checks the flags and the variables above.
2. Detects the hardware: OS, architecture, CPU cores, RAM, GPUs and their memory.
3. Picks the node id and the address, and writes `~/.opod/node.yaml`.
4. Starts its API on the address (see [Worker API](https://opod.io/docs/core-reference/worker-api/)) and calls `POST /admin/v1/nodes/register` on the leader with its hardware, engine, role, KV tier, plan revision and a new boot id.
5. Heartbeats every 5 seconds with the models its engine has loaded, the engine's load and process state.
6. With `OPOD_LOAD_MODEL`, loads that model once the engine answers.

Output:

```text
✔ joining cluster at http://leader:8080 as n_abc123
▶ address: 192.0.2.51:8081
▶ hardware: linux/amd64 · 64 GB RAM
```

After that it logs JSON lines, for example `registered with leader`.

## When the leader answers badly

| Leader answer to a heartbeat                                             | What the worker does                                                                                                                                                                                                                                                                                                                                                                                            |
| ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `404` (the leader forgot the node, for example after `opod node remove`) | Registers again at once.                                                                                                                                                                                                                                                                                                                                                                                        |
| `401` or `403`                                                           | Registers again with the token it started with. A leader that is restarting answers `401` for a moment, so one refusal changes nothing. When **6 re-registers in a row** are refused (about 30 seconds), the worker exits with `join token refused 6 times in a row: the token this worker started with is dead (rotated, or minted by an endpoint that is gone) — exiting so a restart reads the current one`. |
| Network error or `5xx`                                                   | Retries with backoff: 10 s, then 20 s between attempts, until the leader is back.                                                                                                                                                                                                                                                                                                                               |

A failed first register only logs `register failed`; the heartbeat loop then registers again on its `404`.

From core v0.4.6 the worker also says, in one line per kind on stderr, what the leader answered: `registered with leader … as n_… — it is placeable after its first heartbeat (≤5 s)` on stdout once it is in; `the leader at … refused the join token — mint one on the leader: opod token create --node`; `cannot reach the leader at … (…) — check the URL and the firewall`. The JSON log lines stay as they are. A stop the worker chose — 6 refused re-registers, or its port in use (`port … is in use — another opod join on this host? stop it, or give this worker another port with OPOD_ADVERTISE_ADDR (and OPOD_BIND_ADDR)`) — ends with `opod: worker stopped: <cause>` and exit `1`; before, it printed `✔ worker shutdown complete` and exited `0`. In the release after core v0.4.8 the worker binds its port before it registers, so a taken port stops the join before the leader hears of it: the line is `opod: port … is in use — …` (no `worker stopped:`) with exit `1`, and no `registered with leader` line comes first.

## Stopping

On `SIGINT` or `SIGTERM`:

1. The worker sends a **goodbye** heartbeat at once (nothing loaded, engine `stopped`, `worker shutting down`), with a 3-second deadline, so the leader takes it out of rotation now instead of after the heartbeat bound.
2. It lets the requests already running on it finish, for up to `OPOD_DRAIN_SECONDS` (default `10`, `0` = stop at once, at most `3600`). A gang part also waits while a peer still holds a connection to one of its ports.
3. It stops every engine process it started.

```text
✔ worker shutdown complete
```

Give a container a grace period longer than `OPOD_DRAIN_SECONDS`.
