workers.yaml
Added in 2.4
workers.yaml lists the machines Kraft may run steps on. A machine is another computer with the agent CLIs installed and kraft on its PATH. A connected machine runs the steps that work items place on it.
workers:
gpu-box:
ssh: gpu-box # ssh mode: a host or an ~/.ssh/config alias
capacity: 2 # sessions at once, at most; unset: the machine's own limit, else 1
repos: [kraft, infra] # optional; left out means every connected repo
give_up_after: 2h # default 2h; "never" turns the limit off
groups: [gpu, linux] # optional; the groups a step's runner can name
enabled: true # default true; false: running steps finish, nothing new starts
home-server:
token_sha256: "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
local:
capacity: 3 # sessions this machine's own worker runs at once; unset: no limit
groups: [linux] # optional; the local worker joins groups too
enabled: true # default true; false: local steps wait
kraft admin worker add and edit write this file for you. The file doesn't exist until the first machine is added.
| Field | Type | Default | Meaning |
|---|---|---|---|
ssh | string | unset | Ssh mode. A host, user@host or an ssh config alias that Kraft's server dials. |
token_sha256 | string | unset | Dial-in mode. The SHA-256 of the machine's token, as 64 lowercase hex characters. worker add writes it; the token itself is never stored. |
capacity | integer, 1 or more | unset | How many sessions the machine may run at once. The machine's own limit applies too: the lower of the two is used, and one that is unset takes the other. Both unset is 1. See The machine's own limit. |
repos | list of names | every connected repo | Limits the machine to these repos. See Naming a repo. |
groups | list of names | none | The groups the machine is in. A step's runner: can name a group. See Groups. |
give_up_after | 30s, 90m, 2h, 1d or never | 2h | How long a step waits for the other side before it is given up, on the server and on the machine. See When the server is gone. |
enabled | true or false | true | false stops new steps starting on the machine: the ones running finish, a step that names it waits waiting for NAME (disabled), and a group or any skips it. See Disabling a machine. |
Each machine sets exactly one of ssh and token_sha256.
The top-level local: key isn't a machine. It holds the settings of the local worker: capacity, groups and enabled. Adding, editing or removing a machine keeps it.
Names
A machine's name is 1 to 39 lowercase letters, digits, - or _, starting with a letter or digit. A group's name follows the same rule. Machines and groups share one namespace: a group named like a machine, or a machine like a group, is refused. local and any are refused for both: they are placement words.
Naming a repo
An entry in repos matches a connected repo by its id, its name, or the last part of its path. A name that matches no connected repo is refused when you save the file in Settings or add the machine with worker add. A hand edit that names one is shown as a problem on the pending reload.
Two ways to connect
What each mode needs of the value; how a connection runs is in Connecting a machine.
- Dial-in (
token_sha256): the default, whatkraft admin worker add NAMEwith no--sshregisters. It prints the token once. The server must be reachable from the machine, bound beyond loopback with a password, as in Remote access.rotate-token NAMEends the machine's connection and invalidates the old token at once; an ssh machine has no token to rotate. - Ssh (
ssh): the server's ownsshand~/.ssh/configdial the machine, withBatchMode=yes, so the connection never asks for a password.kraftmust be on the remote machine's non-interactivePATH.kraft admin worker add NAME --ssh HOSTconnects once and exits 1 on a failed connect, but keeps the machine saved.
Offline reasons
kraft admin worker list shows offline: and the reason, and kraft admin doctor shows each offline machine as a warning with the same reason.
| Reason | What it means |
|---|---|
never connected | Nothing has dialled in, or the server hasn't connected yet since it started. |
refused: invalid token | The token doesn't belong to any machine. It was removed, rotated or mistyped. |
refused: update kraft on this machine to X.y: ... | The machine runs another major version of Kraft than the server. Update Kraft on the machine. |
refused: incompatible protocol: ... | The machine and the server speak different protocol versions. The reason names both, with each side's Kraft version. Update the older one. |
disconnected: ... | The connection ended, or the other side was silent for 60 seconds. |
ssh: ... | The server's ssh ended before the machine answered. The reason is the last of what ssh printed, such as Permission denied (publickey). |
could not run ssh: ... | The server couldn't start ssh at all. |
What a machine refuses
Kraft refuses, with a 422 when the item is filed or overridden and config_error at launch, an item that names a machine or group not in workers.yaml, a machine not allowed for its repo, or a group none of whose members could take it; an in-place item; and an item with workspace members, which a single bundle doesn't carry.
A repo with submodules isn't refused when the item declares no members: its submodules stay uninitialised on the machine as they do on the server, and Kraft refuses the machine's commits when they add or move a submodule pointer.
A machine without the agent CLI the step needs, or whose setup_command fails, stops the step with the reason in its log.
Related
- Where a step runs: how the local worker and machines fit together, and why.
- Machine verbs:
kraft admin worker add,edit,enable,disable,rotate-token,list,remove,serveandcheck. - MCP tools:
add_worker,edit_worker,rotate_worker_token,list_workersandremove_worker. - Remote access: binding the server beyond loopback.
- Configuration: the other files in the config directory.