Run a cluster of execution nodes
An execution node is a machine that runs an agent's turns on a coding CLI (fx, Claude Code or OpenCode) instead of on the Breign server. A node group gathers several nodes that share a queue, like CI runners: each turn of an agent bound to the group goes to the first free node of the group.
This page shows how to run such a group as a cluster of containers, on Kubernetes or on your own servers. Each container runs the Breign CLI as a node: it signs in with an API key, connects to Breign and joins the group on its own, with no one at the keyboard.
Nodes only open outbound connections to the Breign API: no port has to be exposed.
Before you start​
- You need the right to create node groups in the organization (organization administrators have it).
- The organization must accept new nodes. If node association is restricted to administrators, the account that owns the nodes must be one of them.
- Each node needs outbound HTTPS access to the Breign API and, for fx, to GitHub (the node downloads fx there on first start).
- You need the node image. See Get the image.
1. Create the group​
- In Breign App, open Execution nodes (sidebar, Execution section), then the Groups tab.
- Click New group.
- Give it a Name, for example
Kubernetes runners. The nodes will find the group by this name. - Set the Group rules, or keep the defaults:
- Wait for the node keeping the environment (10 min by default): when the node that holds a conversation's files is busy or offline, how long the next message waits for it before another node takes it, from the conversation history.
- Release an environment after (24 h without activity by default): when nodes delete the files kept for an idle conversation.
- Give up an execution without a node after (24 h by default): how long a turn waits in the queue when no node can take it.
- Leave Nodes empty: the containers will add themselves.
- Click Create group.
2. Create an API key for the nodes​
The nodes belong to the account whose API key they use. Use a dedicated service account for the cluster, with only the rights the nodes need: it is easier to audit and to revoke.
- Sign in to Breign App with that account and open Account settings → API keys.
- Click Create a key, name it, for example
Kubernetes runners. - Copy the key: it will never be shown again.
The account must be a member of the organization and be allowed to edit the group (nodeGroup.update permission).
Agents run on the node under the same system user as the node itself. An agent that has a shell can read the node's API key. Give the cluster an account that has nothing more than what the nodes need.
3. Deploy the nodes​
Every node is configured through environment variables. The minimum is:
| Variable | Value |
|---|---|
BREIGN_ | Your Breign API, for example https://api.breign.eu |
BREIGN_ or BREIGN_ | The API key, or a file that contains it (a mounted secret) |
BREIGN_ | The organization (id, slug or name) |
BREIGN_ | The group's name in that organization, or its id |
Each node keeps its identity, settings and files under /var/lib/breign. Give every node its own volume there. Without a volume, each restart creates a new node in Breign. Two nodes must never share the same volume: they would have the same identity and keep replacing each other's connection.
All the other settings (working folders, slots, models, CLIs) are in the node image reference.
On Kubernetes​
Use a StatefulSet: each pod gets its own volumes and a stable name, which becomes the node's name in Breign (breign-node-0, breign-node-1…).
apiVersion: v1
kind: Secret
metadata:
name: breign-node
namespace: breign
type: Opaque
stringData:
api-key: "<the API key>"
---
apiVersion: v1
kind: ConfigMap
metadata:
name: breign-node
namespace: breign
data:
BREIGN_SERVER: "https://api.breign.eu"
BREIGN_ORG: "my-organization"
BREIGN_NODE_GROUP: "Kubernetes runners"
BREIGN_NODE_SLOTS: "2"
BREIGN_NODE_WORKSPACES: "workspace=/workspace=Workspace"
---
apiVersion: v1
kind: Service
metadata:
name: breign-node
namespace: breign
spec:
clusterIP: None
selector:
app.kubernetes.io/name: breign-node
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: breign-node
namespace: breign
spec:
serviceName: breign-node
replicas: 3
podManagementPolicy: Parallel
selector:
matchLabels:
app.kubernetes.io/name: breign-node
template:
metadata:
labels:
app.kubernetes.io/name: breign-node
spec:
terminationGracePeriodSeconds: 60
securityContext:
runAsNonRoot: true
runAsUser: 10001
runAsGroup: 10001
fsGroup: 10001
containers:
- name: node
image: <node image>
envFrom:
- configMapRef:
name: breign-node
env:
- name: BREIGN_API_KEY_FILE
value: /run/secrets/breign/api-key
- name: BREIGN_NODE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
resources:
requests:
cpu: 500m
memory: 1Gi
limits:
memory: 4Gi
livenessProbe:
exec:
command: ["breign-node-healthcheck", "--live"]
periodSeconds: 30
timeoutSeconds: 15
readinessProbe:
exec:
command: ["breign-node-healthcheck"]
initialDelaySeconds: 10
periodSeconds: 30
timeoutSeconds: 15
volumeMounts:
- name: state
mountPath: /var/lib/breign
- name: workspace
mountPath: /workspace
- name: api-key
mountPath: /run/secrets/breign
readOnly: true
volumes:
- name: api-key
secret:
secretName: breign-node
volumeClaimTemplates:
- metadata:
name: state
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 2Gi
- metadata:
name: workspace
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 10Gi
kubectl create namespace breign
kubectl apply -f breign-nodes.yaml
Do not use a Deployment with a shared ReadWriteMany volume: every pod would get the same node identity.
On servers​
Run one container per node, each with its own volume. With Docker (or Podman, with the same options):
docker run -d --name breign-node --restart unless-stopped \
--stop-timeout 60 \
-e BREIGN_SERVER=https://api.breign.eu \
-e BREIGN_API_KEY=<the API key> \
-e BREIGN_ORG=my-organization \
-e BREIGN_NODE_GROUP="Server runners" \
-e BREIGN_NODE_NAME=server-1 \
-v breign-state:/var/lib/breign \
-v breign-workspace:/workspace \
<node image>
Or with Docker Compose:
services:
breign-node:
image: <node image>
restart: unless-stopped
stop_grace_period: 60s
environment:
BREIGN_SERVER: https://api.breign.eu
BREIGN_API_KEY: ${BREIGN_API_KEY}
BREIGN_ORG: my-organization
BREIGN_NODE_GROUP: Server runners
BREIGN_NODE_NAME: server-1
BREIGN_NODE_SLOTS: "2"
volumes:
- breign-state:/var/lib/breign
- breign-workspace:/workspace
volumes:
breign-state:
breign-workspace:
To run several nodes on the same server, declare one service per node, each with its own volumes and name. docker compose up --scale does not work: the replicas would share the state volume, and only one of them would start.
On a machine where the Breign CLI is installed (npm install -g @breign/cli), the same setup is: BREIGN_SERVER=… BREIGN_API_KEY=… BREIGN_ORG=… breign node start --group "Server runners", run as a service (systemd, launchd). Declare the working folders first with breign node workspace add.
4. Check that the nodes joined the group​
The node's logs are in French. Once a node has joined, its logs end with:
11:11:29 [MATE-LINK] connecté à wss://api.breign.eu/ws/mate
11:11:29 [MATE] enregistré ; 0 trame(s) à rejouer
11:11:30 connecté à Breign
11:11:31 dans le groupe Kubernetes runners (3 nœud(s))
In Breign App, the group page lists the nodes, whether they are online, and their slots.
If the group cannot be found, or the account is not allowed to add the node to it, the node stops with an error and a non-zero exit code: the pod restarts and stays not ready until the problem is fixed.
5. Bind agents to the group​
- Open the agent's configuration page, section Execution.
- Choose Node group.
- Choose the Group, the Working folder (an alias declared by the nodes,
workspacein the examples) and the Runtime (fx, Claude Code or OpenCode). - Optionally turn on Keep the environment: the node that starts a conversation keeps its files and receives the next messages of that conversation.
Only the nodes that declare this working folder and this runtime take the agent's turns. Give every node of the group the same BREIGN_ and the same CLIs.
The group page shows the queue: waiting, running and finished executions, which node took each one, and the environments kept for conversations.
Scale the cluster​
- Add nodes: increase the number of replicas, or start another container with its own volume. New nodes join the group as soon as they are connected.
- Remove nodes: decrease the number of replicas. The removed nodes stay in the group, offline, with their volume: they get their identity back if the number goes up again. Turns waiting in the queue go to the other nodes; conversations whose files were on a removed node wait for it as set in the group rules, then start again on another node.
- Remove a node for good: run
breign node unpairin its container before removing it, or click Unpair on its page in Breign App. An unpaired node receives no more turns.
Updates and restarts​
Stopping a container (docker stop, a pod deletion, a rolling update) sends SIGTERM: the node interrupts the running turn, then disconnects. Leave it a few seconds (60 s in the examples). An interrupted turn resumes on its own if the agent has Automatic resume.
A node that restarts with its volume keeps the same identity and goes back to its group without creating a duplicate.
If something goes wrong​
- A new node appears in Breign at every restart: the node has no persistent volume on
/var/lib/breign. - Two nodes keep disconnecting each other (« Une connexion plus récente remplace celle-ci » in the logs): they share the same state volume. Give each node its own.
le nœud tourne déjà sur cette machine: a second container uses the volume of a running node.aucun groupe « … » dans l'organisation: checkBREIGN_andNODE_ GROUP BREIGN_, or use the group's id.ORG - The node is connected but never takes turns: check that it declares the agent's working folder and runtime (
breign node statusin the container), and that it has free slots. - Claude Code turns fail: the image must be built with Claude Code, and
ANTHROPIC_must be set. See the node image reference.API_ KEY