---
title: "opod node"
description: "List and inspect the cluster's nodes, drain and undrain them, and remove a node from the leader."
url: "https://opod.io/docs/core-cli/node/"
markdown_url: "https://opod.io/docs/core-cli/node.md"
section: "Core CLI"
last_updated: "2026-10-30"
---

# opod node

> List and inspect the cluster's nodes, drain and undrain them, and remove a node from the leader.

## In short

`opod node` lists the machines the leader knows and takes them in and out of rotation. A drain stops new requests to a node and lets running ones finish; a remove makes the leader forget it. Run it on the leader host.

```bash
opod node drain n_abc123
```

```text
✔ n_abc123 is draining (through the running leader): it gets no new requests and no new shard parts; requests already on it finish. A sharded model with a part on it stops serving.
▶ it stays drained across heartbeats and a worker restart — undo with `opod node undrain n_abc123`
```

## Usage

```text
opod node ls
opod node show ID
opod node drain ID
opod node undrain ID
opod node remove ID [--yes]
```

A node is one machine the leader knows: the leader itself (id `local`) and every worker that joined with `opod join`. Run these commands on the leader host, as the user that runs `opod up`: they read `~/.opod/config.yaml`, the store at `storage.dsn` (`~/.opod/state.db` by default) and the admin key in `~/.opod/admin.key`.

| Sub-command  | Aliases | How it reaches the leader's state | Works with no leader running |
| ------------ | ------- | --------------------------------- | ---------------------------- |
| `ls`         | `list`  | reads the store                   | yes                          |
| `show ID`    | —       | reads the store                   | yes                          |
| `drain ID`   | —       | admin API, else the store         | yes                          |
| `undrain ID` | —       | admin API, else the store         | yes                          |
| `remove ID`  | `rm`    | admin API, else the store         | yes                          |

Node ids come from `opod node ls`. A worker's id is `OPOD_NODE_ID` if its manager set one, else the id saved in the worker's `~/.opod/node.yaml`, else `n_<POD_NAME>`, else a random `n_` plus 8 characters. See [`opod join`](https://opod.io/docs/core-cli/join/#identity-and-address).

## opod node ls

```bash
opod node ls
```

```text
ID             HOSTNAME             OS/ARCH      ADDRESS                STATE      LAST HB
local          leader-1             linux/amd64  127.0.0.1:8080         ready      2026-10-30T10:12:44Z
n_abc123       node-a               linux/amd64  192.0.2.51:8081        ready      2026-10-30T10:12:42Z
n_def456       node-b               linux/amd64  192.0.2.52:8081        draining   2026-10-30T10:12:41Z
n_ghi789       node-c               linux/amd64  192.0.2.53:8081        lost       2026-10-30T10:02:10Z
```

| Column     | Meaning                                                                                                                 |
| ---------- | ----------------------------------------------------------------------------------------------------------------------- |
| `ID`       | The node id. The leader's own row is always `local`; `opod up` writes it at start with the address `127.0.0.1<listen>`. |
| `HOSTNAME` | What the worker reported at register.                                                                                   |
| `OS/ARCH`  | `GOOS/GOARCH` of the worker binary.                                                                                     |
| `ADDRESS`  | Where the leader dials the worker: its LAN address on port `8081`, or `OPOD_ADVERTISE_ADDR`.                            |
| `STATE`    | The state the leader acts on (below).                                                                                   |
| `LAST HB`  | The last heartbeat, RFC 3339. Workers heartbeat every 5 seconds.                                                        |

With no nodes yet, it prints ``(no nodes registered yet — issue a join token: `opod token create --node`)``.

There is no `--json`. For machine output, call `GET /admin/v1/nodes` (see [Admin API](https://opod.io/docs/core-reference/admin-api/)). From core v0.4.6, `opod node ls --json` prints the same rows as a list (`id`, `hostname`, `platform`, `address`, `state` — the live one — and `last_heartbeat`), and an extra argument is a usage error.

### States

`STATE` is computed when the row is read, by the same rule the router uses to pick a worker. So a node reads `lost` here at the moment the leader stops sending it requests.

| State           | Stored or derived     | Meaning                                                                                                                                                                                                                                                   |
| --------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `joining`       | stored                | A pre-ready state the store and router understand. Core's own register writes `ready` directly, so you do not normally see it; a heartbeat moves a `joining` row to `ready`.                                                                              |
| `ready`         | stored                | In rotation.                                                                                                                                                                                                                                              |
| `draining`      | stored                | You drained it. It gets no new requests and no new gang parts. It stays `draining` even when its heartbeats stop.                                                                                                                                         |
| `lost`          | derived, never stored | A `ready` or `joining` node whose last heartbeat is older than the heartbeat bound: `router.heartbeat_max_age_seconds`, default `30`; `0` means a 60-second bound.                                                                                        |
| `engine-silent` | derived, never stored | The worker heartbeats, but its engine has not answered it for longer than the same bound (a 60-second bound when the setting is `0`). The worker is alive and nothing says what it serves, so it gets no new work. A drained node still reads `draining`. |

A drain also survives a worker restart: a worker that registers again under a drained id stays `draining`.

When a `lost` worker heartbeats again, it is back in rotation at once. You do nothing.

## opod node show

```bash
opod node show n_abc123
```

Prints the node's stored record as indented JSON, plus `loadedModels`: the models placed on it, from the heartbeat-reconciled placement rows.

```json
{
  "ID": "n_abc123",
  "Hostname": "node-a",
  "OS": "linux",
  "Arch": "amd64",
  "RAMGB": 64,
  "Address": "192.0.2.51:8081",
  "WorkerToken": "sk-orc-<printed once>",
  "BoundKeyID": "k_…",
  "HardwareJSON": "{\"Hostname\":\"node-a\",\"OS\":\"linux\",\"Arch\":\"amd64\",\"CPUCores\":16,\"RAMGB\":64,\"GPUs\":[{\"Name\":\"…\",\"VRAMGB\":48}],\"Engine\":\"vllm\"}",
  "LastHeartbeat": "2026-10-30T10:12:42.118Z",
  "State": "ready",
  "BootID": "…",
  "EngineSilentSince": "0001-01-01T00:00:00Z",
  "loadedModels": ["llama-3.2-3b"]
}
```

The store record has no JSON tags, so its keys are the Go field names. `State` here is the **stored** value, not the derived one: a lost node still shows `ready`. `HardwareJSON` is what the worker registered, as a JSON string: `Hostname`, `OS`, `Arch`, `CPUCores`, `RAMGB`, `GPUs` (each `Name`, `VRAMGB`), and when set `Engine`, `Role`, `KVTier` and `PlanRevision` (and, from core v0.4.7, `KVEvents: true` for a worker started with `OPOD_KV_EVENTS=1`). `BootID` names the worker process; it changes on every worker restart. A zero `EngineSilentSince` means the engine answers.

> **The output holds a secret, up to 0.3.0**
>
> `WorkerToken` is the secret the leader signs its calls to that worker with. Up to and including 0.2.1 it is printed whole: treat that output as a secret and do not paste it into a ticket. In 0.3.0 it is redacted to its prefix and last four characters (`sk-orc…6789`). `GET /admin/v1/nodes` still carries it whole in both, because front doors read it there to call the workers.

`opod node show` with no id prints `opod: usage: opod node show <id>`. An unknown id prints `opod: no such node: <id>`. From core v0.4.6, `opod node show <id>` prints a short human summary (the live state, the last heartbeat, platform, RAM, address and what is loaded) and `--json` prints the record above; an unknown id says `no node <id> (see opod node ls)`.

## opod node drain

```bash
opod node drain n_abc123
```

```text
✔ n_abc123 is draining (through the running leader): it gets no new requests and no new shard parts; requests already on it finish. A sharded model with a part on it stops serving.
▶ it stays drained across heartbeats and a worker restart — undo with `opod node undrain n_abc123`
```

What happens:

1. The CLI calls `POST /admin/v1/nodes/{id}/drain` on the leader, so the change is on the leader's event stream.
2. The leader sets the node's state to `draining`. The router stops choosing it from the next request.
3. Requests already on the node finish. The worker keeps running and keeps heartbeating.
4. A gang with a part on that node stops serving, because a gang needs every part.

A drain does not unload models and does not stop the worker. To move a model off the node with no failed request, use [`opod model move`](https://opod.io/docs/core-cli/model/#opod-model-move) before or instead.

The leader's own node cannot be drained:

```text
opod: the leader's own node cannot be drained — unload its models (`opod model unload <id>`) or stop the leader (`opod down`)
```

From core v0.4.6, draining a node that is already draining says `… is already draining — nothing changed` and exits `0`; undraining one that is not drained says `… is not drained — nothing changed`. The check reads this host's store, so it applies on the leader's host.

## opod node undrain

```bash
opod node undrain n_abc123
```

```text
✔ n_abc123 is back in rotation (through the running leader): the router may choose it from the next request on
```

It sets the stored state back to `ready`. A node that is still not heartbeating then reads `lost`.

## opod node remove

```bash
opod node remove n_abc123         # asks: Remove node "n_abc123" from the cluster? … (y/N)
opod node remove n_abc123 --yes   # no prompt; -y is the same
```

The prompt accepts `y` or `yes`. Anything else, or a stdin that is not a terminal, answers no and the command exits with `opod: aborted`. Scripts pass `--yes`.

Through a running leader (`DELETE /admin/v1/nodes/{id}`), the leader deletes the node row and its placements, and its router drops the node's cached connection, its cooldown and its sticky-session pins:

```text
✔ removed n_abc123 (through the running leader): its placements are gone and the router dropped its cached connection, cooldown and sticky pins
```

The worker process keeps running. Its next heartbeat gets `404`, and a worker that gets `404` registers again. So a node you remove while it runs comes back within about 5 seconds. Stop the worker first (Ctrl-C or `SIGTERM` on `opod join`) if you want it gone.

## Leader or store

`drain`, `undrain` and `remove` call the running leader first. They fall back to writing the store directly only when **no leader answered** — not when the leader refused. The output names which path ran:

| Output says                                 | Meaning                                                                                                                                                                                                                                                   |
| ------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `through the running leader`                | The leader took the change. It is on the event stream, and for `remove` the router's in-memory state is cleared too.                                                                                                                                      |
| `written to the store — no leader answered` | No leader was reached. The row was changed in `state.db`; a leader started later reads it. On 0.2.1 a host with no `admin.key` also lands here while a leader runs; from 0.3.0 that case is refused, naming the leader that answered and the missing key. |

A leader that answers with an error is final. The CLI prints its status and body, for example `opod: drain n_x: POST /admin/v1/nodes/n_x/drain: 404 Not Found: …`, and changes nothing.

> **No admin key means no leader**
>
> The CLI reaches the leader with the key in `~/.opod/admin.key`, at `http://localhost<listen>`. When that file is missing (a managed leader writes none), the call never leaves the CLI, so it counts as "no leader answered" and the CLI writes the store, even when a leader is running. A running leader then does not see the change on its event stream, and after a store-only `remove` its router still holds the old connection. On such a host, use the admin API with an admin key instead.
>
> From core v0.4.6 this changes. The CLI also uses the admin token the leader was started with (`OPOD_ADMIN_TOKEN`), so on a managed leader the call goes through the leader. `node ls` and `node show` ask the running leader first too. On a managed host (`OPOD_MANAGED=1`) a command never writes or reads a store of its own: with no leader answering it refuses and says so. See [Core CLI](https://opod.io/docs/core-cli/#where-commands-act).

With no leader and an unknown id, the store path prints `opod: drain n_x: no such node` (or `remove n_x: no such node`).

## Add a node

```bash
opod token create --node                                        # on the leader; the key is printed once
opod join "http://leader:8080?token=sk-orc-<node-token>"        # on the new machine
```

Quote the URL: `?` is a glob character in zsh. See [`opod join`](https://opod.io/docs/core-cli/join/) and [Clusters](https://opod.io/docs/core/clusters/).
