Deploy

kōjō has two supported installs: a single VM, with Postgres in Docker Compose and kōjō on the host, and a Helm chart for Kubernetes. Each has a page of its own. This page covers what applies to both: high availability, upgrades, secrets, sizing and the container images. It is for operators. Install has the short path to a first session.

A small factory module with an orange door on a concrete pad, piped to a cylindrical storage tank. A small factory module with an orange door on a concrete pad, piped to a cylindrical storage tank.
One binary and Postgres: the factory, and the tank it keeps its records in.

The installs

Install Sandbox driver Page
One VM: Postgres in Docker Compose, kojo serve on the host as a systemd service, TLS from a reverse proxy, backups with pg_dump sbx Single VM with Compose
Kubernetes: what the chart installs, kojo.yaml and the values, the proxy deployment, RBAC, network policies, the runtime class, Agent Sandbox, secrets, the database, traffic k8s, or e2b Kubernetes with Helm

To run kojo-proxy as its own process, apart from the server, see Running kojo proxy separately.

High availability

Several kojo serve processes can run against one database. Postgres coordinates them; there is no other shared state, no Kubernetes Lease and no leader process.

Work How replicas share it
HTTP: dashboard, API, webhooks Every replica serves it. They need the same server.auth.session_secret, or each signs cookies with its own key.
Sessions Every replica runs server.workers sessions at a time, 4 by default. A worker claims the next queued session with FOR UPDATE SKIP LOCKED, so two workers never take the same one.
A session’s lock A claim lasts 2 minutes and the worker renews it every 30 seconds. When a replica dies, its sessions’ locks expire and another worker claims them and resumes from the last checkpoint.
Duplicate requests A webhook delivery, a chat message and a scheduled run each carry a dedupe key with a unique constraint, so a retried delivery does not start a second session.
Scheduler Every replica runs the loop, every 30 seconds. Only the one that gets a Postgres advisory lock for that tick fires schedules. Each scheduled run also has a dedupe key.
Migrations Serialized with a Postgres advisory lock.
Runtime config A change is announced with NOTIFY; every replica listens and reloads it without a restart. A replica whose listen connection dropped reloads everything when it reconnects.
Expired sandboxes Every replica runs the reaper every 5 minutes.
kojo-proxy policies (remote mode) Each kōjō replica sends the policies of the sandboxes it starts to every proxy replica, and sends a proxy replica that restarted or appeared the ones it lacks.

kojo-proxy in remote mode runs as several replicas too, 2 in the chart. Each holds every sandbox’s policy in memory, and kōjō finds them through a headless Service (sandbox.proxy.admin_discovery: dns). A new or restarted proxy replica takes no sandbox traffic until a kōjō server has sent it the policies; the chart gives the proxy a PodDisruptionBudget and soft pod anti-affinity of its own. See Several replicas.

What cannot be replicated:

  • The sbx driver: sandboxes belong to the sbx daemon of one host, so a single-VM install is one kōjō process. High availability means the k8s driver.
  • Postgres is the single point of state. The bundled Postgres of the chart is one replica without backups; use a managed or replicated Postgres for production.

On shutdown a replica stops accepting requests, lets each session in flight save its checkpoint and hands it back to the queue, where another replica or the next start resumes it. On Kubernetes the chart defaults to 2 replicas, a PodDisruptionBudget that keeps one available, and soft pod anti-affinity (podAntiAffinity: soft, or hard).

Upgrades

One version tag covers the binary, the image and the chart. Upgrade all of them to the same version.

  1. Read the release notes on the GitHub Release.
  2. Back up Postgres.
  3. Install the new version. The new kojo serve applies pending migrations when it starts.
  4. Run kojo doctor.

On one VM:

curl -fsSL https://xavidop.github.io/kojo/install.sh | sh -s -- --version v0.3.1
sudo systemctl restart kojo
kojo doctor --remote --token "$KOJO_ADMIN_TOKEN"

On Kubernetes:

helm upgrade kojo oci://ghcr.io/xavidop/charts/kojo --version "$KOJO_VERSION" -n kojo --reuse-values
kubectl -n kojo exec deploy/kojo -- kojo doctor -f /etc/kojo/kojo.yaml

To apply migrations as a separate step, run kojo migrate -f kojo.yaml with the new binary before you restart the server. It prints how many it applied.

What the code does and does not do:

  • Migrations are numbered, applied in order, each in its own transaction, and recorded in the table kojo_migrations. A released migration is never edited; a change is a new migration.
  • There are no down migrations. To roll back past a migration, restore the backup you took before the upgrade and run the old version.
  • An old binary does not check for a schema newer than its own. During a rolling update old pods keep running against the migrated schema until they are replaced. The code states no compatibility guarantee for that window.
  • Sessions in flight survive a restart: they are checkpointed in Postgres and resumed, with the config revisions they started with.

Secrets

References in kojo.yaml

kojo.yaml names secrets and holds none. The loader replaces references to environment variables before it validates the file:

Syntax Meaning
${NAME} The value of the environment variable NAME.
${NAME:-default} The value of NAME, or default when it is not set or empty. ${NAME:-} makes a variable optional.
$$ A literal $.

The rules, from internal/config/load.go:

  • A variable that is not set, or set to the empty string, without a default is an error. kōjō refuses to start and lists every missing variable in one message.
  • References are replaced in values only: never in keys, and never in comments, so a block you leave commented out does not ask for its variables.
  • Substitution works on the parsed YAML, not on its text. A value stays one scalar whatever it contains: a password with # or : , a PEM key with line breaks.
  • An unquoted value keeps YAML’s typing after substitution, so workers: ${KOJO_WORKERS:-4} is a number. A substituted value never becomes null.
  • Inside { } or [ ] a reference must be quoted, because the braces are YAML syntax there: tokens: [{name: admin, token: "${KOJO_ADMIN_TOKEN}"}].
  • Unknown keys are errors.

Check a file and its environment without starting anything:

kojo config validate -f kojo.yaml

Where secret values live

Install Variables Files
Single VM .env, loaded by systemd as /etc/kojo/kojo.env (mode 0640, root:kojo) /etc/kojo/secrets/
Helm secrets.existingSecret, loaded with envFrom Secrets mounted with extraVolumes

Secrets that are files: forges.github.private_key_file, and the proxy’s CA (sandbox.proxy.ca_cert_file, ca_key_file).

What must never be in the config

Do not write these values into kojo.yaml, a values file or a ConfigMap. Reference a variable or a file instead:

  • server.auth.session_secret, server.auth.tokens[].token, server.auth.oidc.client_secret
  • the password in database.url
  • forges.github.private_key and webhook_secret, forges.gitlab.token and webhook_secret, forges.forgejo.token and webhook_secret
  • chat.slack.bot_token, app_token, signing_secret
  • models.gateway_api_key, models.providers.*.api_key
  • sandbox.proxy.admin_token

Runtime configuration never holds a secret either: skills and settings name credentials (github, gitlab, forgejo, bitbucket), and the dashboard has no field to enter one. Rotating a secret is a change to .env or to a Kubernetes Secret, followed by a restart.

GitHub clone credentials for sandboxes are short-lived installation tokens. GitLab, Forgejo and Bitbucket clone credentials are the configured token itself, which is not short-lived and not scoped. kojo-proxy treats every forge clone credential as read-only: it sets it on GET, HEAD and OPTIONS requests and on git’s fetch, and a push or a writing API call goes out without it. Docker Sandboxes’ own proxy cannot enforce that, so with the sbx driver a GitLab, Forgejo or Bitbucket token in a sandbox’s route can write. See Security.

Sizing

The repository gives no sizing guidance and no performance numbers. These are the settings and defaults that determine load:

What Default Where
Sessions at once per replica 4 server.workers
Replicas 2 in the chart, 1 on a single VM replicaCount
kojo-proxy replicas 2 in the chart; none on a single VM with sbx proxy.replicaCount
Database connections per replica the driver’s default, the larger of 4 and the number of CPUs; at least 2, whether set here or as pool_max_conns in the database URL database.max_conns
Sandbox lifetime 4 hours sandbox.ttl
Resources of one sandbox set by the skill’s kit; the built-in fix-bug asks for 4 CPUs, 8Gi of memory and 40Gi of disk kit.yaml
Bundled Postgres volume 8Gi postgresql.persistence.size

The kōjō process itself mostly waits: on model calls and on commands that run in sandboxes. What drives resource use is the number of concurrent sessions (replicas times server.workers) and what each session’s sandboxes ask for. What drives cost is model calls; cap it with models.budgets. The daily cap is a rolling 24-hour sum over the whole install, evals included: once it is reached, sessions that have not started wait and are looked at again every 10 minutes, and running ones stop at their next model call. Postgres grows with the session steps and the audit log, which is append-only.

The container image

ghcr.io/xavidop/kojo is built from the Dockerfile for linux/amd64 and linux/arm64. One image runs both workloads.

Property Value
Base gcr.io/distroless/static:nonroot, pinned by digest. No shell, no package manager.
Contents /usr/local/bin/kojo, and the licence files under /usr/share/doc/kojo/.
User 65532:65532, by number, so Kubernetes’ runAsNonRoot can verify it.
Working directory /var/lib/kojo, kōjō’s state directory, owned by that user.
Entrypoint kojo
Default command serve -f /etc/kojo/kojo.yaml
Ports 8080 (dashboard, API, webhooks, MCP, /healthz, /readyz), 9090 (/metrics), 3128 (the egress proxy), 3129 (the admin API of kojo proxy).

Because the image has no shell and no HTTP client, a container health check cannot call /healthz from inside. Probe from outside, as the chart’s probes do.

Release images are signed with cosign by digest:

cosign verify ghcr.io/xavidop/kojo:0.3.1 \
  --certificate-identity-regexp 'https://github.com/xavidop/kojo/' \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com

make docker builds the image locally as ghcr.io/xavidop/kojo:dev.

The sandbox toolchain image

A second image, ghcr.io/xavidop/kojo-toolchain, is what a sandbox runs when a skill’s kit names no image and sandbox.image is not set. It is not part of kōjō’s own deployment; the sandbox driver pulls it. Its Dockerfile is deploy/toolchain/Dockerfile.

Property Value
Base debian:trixie-slim, pinned by digest.
Contents bash, git, make, a C toolchain, curl, jq, ripgrep, Python 3 with pip and venv, the Docker client with buildx and compose (no engine), and Node.js and Go, pinned by version and checksum.
User agent, uid 1000, not root. Docker Sandboxes’ base image contract asks for it.
Working directory /workspace, owned by that user.
Default command sleep infinity. The drivers start their own commands.

It holds no secret and nothing to configure: credentials never enter a sandbox. The Release workflow builds it for linux/amd64 and linux/arm64, smoke-tests it, pushes it at the version of the release and as latest, and signs it. kōjō looks for it at its own version. make toolchain builds it locally as ghcr.io/xavidop/kojo-toolchain:dev and runs the same smoke test.

In a cluster or on a host that cannot pull from ghcr.io, mirror the image and set sandbox.image to the mirror.

Scroll to move. + - zoom, 0 fit, Esc close.100%