Skip to content

Operations ​

The orbit binary is both the server and the operator's tool. This page covers the operator commands. How to run them in the self-hosted stack (the migrate container, docker compose run --rm migrate orbit ...) is in deploy/README.md; this page does not repeat it.

CommandConnectionSecretsChanges data
orbit migrateownernoneschema only
orbit tenant provisionownerORBIT_AUDIT_KEYyes, audited
orbit keys rotateownerORBIT_DATA_KEY, ORBIT_AUDIT_KEYyes, audited
orbit keys rewrapownerORBIT_DATA_KEY, ORBIT_DATA_KEY_PREVIOUS, ORBIT_AUDIT_KEYyes, audited
orbit keys destroyownerORBIT_AUDIT_KEYyes, for good, audited
orbit healththe ones it is givennoneno

"Owner" is ORBIT_MIGRATION_DATABASE_URL. No serving process may hold it, so these commands run in their own short-lived process, never in web or worker (ADR 0004). Each connects, checks that the owner login is not a superuser and has no BYPASSRLS, does its work and exits.

Every command logs JSON lines to standard output (filter with RUST_LOG). It exits with 0 on success and 1 on any error, after logging orbit stopped with an error with the reason. Secrets are never logged.

orbit migrate ​

text
Runs every migration, then exits

The kernel's, the platform's and every compiled module's, in the shared database and in every database listed in ORBIT_DATABASES (or ORBIT_DATABASES_FILE), each with its owner URL. Needs ORBIT_MIGRATION_DATABASE_URL, which the serving roles refuse.

Usage: orbit migrate [OPTIONS]

Options:
      --database <DATABASE>
          Migrate only this database (`shared` or a name from ORBIT_DATABASES)

  -h, --help
          Print help (see a summary with '-h')

Runs the migrations of the kernel, the platform crates (authorisation, personal data, doors, MCP, events, jobs) and every module compiled into this binary, then records each module and its dependencies in kernel.modules. It is safe to run again: applied migrations are skipped.

Run it before starting a new build. Until it has run, enabling a module that the new build added is refused with CONFLICT. The self-hosted stack runs it as the one-shot migrate container and starts web and worker only after it succeeds.

Upgrading to the release with issue #31 (snapshot chains): a core.snapshot, leave.snapshot or attendance.snapshot job queued by an older build has no chain id, so it runs without the guard that stops a chunk that already ran. Let the worker drain those jobs before migrating (SELECT job_type, count(*) FROM apalis.jobs WHERE job_type LIKE '%.snapshot' AND (status IN ('Pending', 'Running') OR (status = 'Failed' AND attempts < max_attempts)) GROUP BY 1 returns nothing), or run core.events.reemit after the upgrade if one was retried.

Before any migration it checks the database (ADR 0005), in this order: PostgreSQL 16 or later; orbit_role_admin and its orbit_roles.ensure_module_role (installed by the superuser's deploy/postgres/init/02-module-roles.sql); and that runtime roles can no longer call pg_catalog.set_config. It refuses with a message pointing to deploy/README.md otherwise. ORBIT_ALLOW_SET_CONFIG=1 accepts the last one, for a managed provider that cannot revoke set_config, and logs a warning on every run. It also gives every runtime login the module roles, so run it after adding one; retiring a login means revoking orbit_runtime and running it again.

With dedicated databases configured (ORBIT_DATABASES or ORBIT_DATABASES_FILE, see ADR 0011), orbit migrate migrates the shared database first and then each listed one with its owner URL, and records each database's name (kernel.database_identity); --database <name> migrates one only. A database keeps the name it was first migrated under, and every process refuses a pool whose database answers to another name. Run deploy/postgres/init/02-module-roles.sql and 03-tenant-moves.sql as the superuser in every database first.

Backups and maintenance ​

pg_dump, pg_restore, vacuumdb and reindexdb call pg_catalog.set_config, which only the superuser and the database owner (orbit_migrator) may call. Run them as one of those, never as a runtime, worker or doors login.

With dedicated databases, back up each one on its own. The shared database holds every tenant's placement and sign-in mapping: restore it together with the databases it names (ADR 0011).

orbit tenant provision ​

text
Creates a tenant for an auth-sidecar organisation, so its members' tokens are accepted. Runs migrations first. Needs ORBIT_MIGRATION_DATABASE_URL and ORBIT_AUDIT_KEY

Usage: orbit tenant provision [OPTIONS] --org-id <ORG_ID> --name <NAME>

Options:
      --org-id <ORG_ID>      The sidecar's organisation id (the tokens' `org_id`)
      --name <NAME>          Display name of the tenant
      --module <MODULES>     A module to enable (repeat; dependencies first)
      --database <DATABASE>  The database that holds the tenant's data (`shared`, or a name from ORBIT_DATABASES, whose owner URL is then needed) [default: shared]
  -h, --help                 Print help

The only way to create a tenant (ADR 0002). It refuses an organisation that is already provisioned. It runs orbit migrate first, then creates the tenant, maps the organisation to it, enables the listed modules in order and writes an audit entry (kernel.tenant.provision). The new tenant's id is in the tenant provisioned log line; the orbit keys commands need it. deploy/bootstrap.sh calls this for the first organisation.

--database <name> creates the tenant in a database listed in ORBIT_DATABASES (its owner URL is needed) and records its placement in the shared database; the organisation's mapping stays in the shared database. Restart the scheduler afterwards so it schedules the new tenant's jobs.

orbit tenant move ​

text
orbit tenant move --tenant <ID> --to <NAME>   # freeze, copy, verify, switch
orbit tenant move --tenant <ID> --finish      # delete the source's copy
orbit tenant move --tenant <ID> --abort       # go back to the source, before --finish

Moves a tenant's data to another database (ADR 0011). It needs ORBIT_MIGRATION_DATABASE_URL, the owner URLs in ORBIT_DATABASES and ORBIT_AUDIT_KEY, and runs only here, never in a serving process.

  • --to audits kernel.tenant.move, sets the placement to moving (writes for the tenant are refused from then on with CONFLICT, reason tenant_moving; reads go on), waits for writes already in flight, copies every table holding the tenant's rows in one snapshot, checks each table's row count and checksum, and switches the tenant to the target (moved_from). It logs one copied line per table. If it fails, nothing is switched and the source stays authoritative but frozen: run it again, or --abort.
  • --finish deletes the tenant's rows (and queue rows) from the source, only if the source still matches what was verified at the switch, and audits kernel.tenant.move.finish. If it fails part way, run it again; --abort is refused from then on.
  • --abort before the switch deletes the target's partial copy and unfreezes; after it, only if nothing has been written to the target since (otherwise run --finish and move it back), and only while the source still holds the verified copy. It audits kernel.tenant.move.abort.

Only one of these commands runs at a time for a tenant; another is refused until it ends.

Restart the scheduler, and any worker with an allowlist, after a move. The owner of each database must be allowed to set session_replication_role (deploy/postgres/init/03-tenant-moves.sql); the command refuses otherwise.

Dedicated deployment mode ​

ORBIT_TENANT_ALLOWLIST (tenant ids, comma-separated) on the web, worker and scheduler makes the instance serve those tenants only: other tenants' tokens are UNAUTHENTICATED, the bus refuses their dispatches like an unknown tenant, the relay holds their events, and the job worker hands their jobs back to the queue to be claimed again a minute later (keeping their attempts, so no retry is used up and a job that keeps failing elsewhere still ends dead-lettered). The worker and relay start only on the databases where kernel.placements puts an allowlisted tenant (as its database or a move's peer), read at startup, so restart them after a move. Keep a worker without an allowlist running on every database that also holds other tenants. With one database per tenant this gives a single-tenant install.

Two warnings in the worker's log point at a missing step:

  • allowlisted tenant has no placement: treated as on the shared database (at startup): an id in ORBIT_TENANT_ALLOWLIST has no kernel.placements row. Check the id; a tenant provisioned without --database is on the shared database, which is correct.
  • an allowlisted tenant is now placed on a database this worker does not serve: restart it (checked every five minutes): a move put one of its tenants on a database where this worker started no job worker or relay. Restart it.

Each process names its apalis workers <job name>@<instance>, with a random instance id that is new at every start (logged as instance in job worker started). So every process holds and heartbeats its own job locks: a hand-back releases only its own rows, and the jobs a crashed process had locked are recovered once its heartbeat goes stale, even while other instances keep running. Worker rows not seen for a week that no job still names as its lock are pruned.

orbit keys ​

text
Personal-data keys (operator commands; they use the owner connection)

Usage: orbit keys <COMMAND>

Commands:
  rotate   Adds a new data key version for a tenant; later writes use it. Needs ORBIT_MIGRATION_DATABASE_URL, ORBIT_DATA_KEY and ORBIT_AUDIT_KEY
  rewrap   Re-wraps every tenant's data keys under the current ORBIT_DATA_KEY, after a master key change (with the old key in ORBIT_DATA_KEY_PREVIOUS). Resumable: run it again until it reports nothing left. Needs ORBIT_MIGRATION_DATABASE_URL, ORBIT_DATA_KEY, ORBIT_DATA_KEY_PREVIOUS and ORBIT_AUDIT_KEY
  destroy  Crypto erasure: destroys one data key version of a tenant, for good. Everything sealed under it becomes unreadable. Refuses the current version. Needs ORBIT_MIGRATION_DATABASE_URL and ORBIT_AUDIT_KEY
  help     Print this message or the help of the given subcommand(s)

Options:
  -h, --help  Print help

The migrate container does not hold ORBIT_DATA_KEY. Pass it only to the commands that need it (rotate, rewrap). What the keys protect, and the limits of erasure, are in Security model.

orbit keys rotate ​

text
Adds a new data key version for a tenant; later writes use it. Needs ORBIT_MIGRATION_DATABASE_URL, ORBIT_DATA_KEY and ORBIT_AUDIT_KEY.

Queues every module's re-encryption job for the tenant. Values sealed under older versions stay readable until those jobs move them; only then destroy the old versions.

Usage: orbit keys rotate --tenant <TENANT>

Options:
      --tenant <TENANT>
          The tenant's id (a UUID, as in `kernel.tenants`)

  -h, --help
          Print help (see a summary with '-h')

--tenant is the tenant id (a UUID). The command refuses an unknown tenant, adds the next key version and, in the same transaction, queues the re-encryption job of every table with sealed columns in this build (core employees, leave applications, attendance check-in locations, payroll's tables). It audits pii.keys.rotate and logs the new version number. The worker then moves each table in batches; each job logs re-encryption complete when its table is done. A job of a module that is disabled for the tenant is skipped: its rows stay under the old version until the module is enabled again and the tenant is rotated again.

orbit keys rewrap ​

text
Re-wraps every tenant's data keys under the current ORBIT_DATA_KEY, after a master key change (with the old key in ORBIT_DATA_KEY_PREVIOUS). Resumable: run it again until it reports nothing left. Needs ORBIT_MIGRATION_DATABASE_URL, ORBIT_DATA_KEY, ORBIT_DATA_KEY_PREVIOUS and ORBIT_AUDIT_KEY

Usage: orbit keys rewrap

Options:
  -h, --help  Print help

To change the master key:

  1. Generate a new one (openssl rand -hex 32) and back it up away from the database.
  2. Restart web and worker with ORBIT_DATA_KEY=<new> and ORBIT_DATA_KEY_PREVIOUS=<old>. They can then read keys wrapped under either.
  3. Run orbit keys rewrap with both keys. It re-wraps each tenant's key rows (no data is re-encrypted), audits pii.keys.rewrap per tenant, and exits with an error while any tenant is left. Run it again until it succeeds.
  4. Remove ORBIT_DATA_KEY_PREVIOUS and restart web and worker.

The exact compose commands are in deploy/README.md.

orbit keys destroy ​

text
Crypto erasure: destroys one data key version of a tenant, for good. Everything sealed under it becomes unreadable. Refuses the current version (the newest one that unwraps), a version that module tables still hold values under (it lists the tables and row counts; let re-encryption finish first), and a tenant with a module this build does not include. Needs ORBIT_MIGRATION_DATABASE_URL, ORBIT_DATA_KEY and ORBIT_AUDIT_KEY

Usage: orbit keys destroy [OPTIONS] --tenant <TENANT> --version <VERSION>

Options:
      --tenant <TENANT>
          The tenant's id (a UUID, as in `kernel.tenants`)

      --version <VERSION>
          The key version to destroy (`version` in `pii.tenant_keys`); never the current one

      --yes-destroy-data
          Confirms that the data sealed under this version is to be destroyed

Without --yes-destroy-data it refuses before connecting. It refuses:

  • the tenant's current version (run orbit keys rotate first);
  • a tenant that has a module (enabled or not) this build was not compiled with, naming it: run the command from a build that includes every module the tenant uses;
  • a version that any re-encrypted table still holds values under, listing each table and its row count: wait for the jobs orbit keys rotate queued, then retry. It first waits for writes in progress that loaded the tenant's keys, so a value written under the old version just before is counted;
  • a version that does not exist or is already destroyed.

On success it audits pii.keys.destroy. There is no undo, except restoring a backup that still holds the key row. Files (orbit_storage blobs) are not part of the check.

orbit health ​

text
Checks that the database connections this process was given answer, then exits

For container health checks: exit 0 when ORBIT_DATABASE_URL and, if set, ORBIT_WORKER_DATABASE_URL and ORBIT_DOORS_DATABASE_URL each answer `SELECT 1`.

Usage: orbit health

Options:
  -h, --help
          Print help (see a summary with '-h')

Each connection gets 3 seconds. It does not check the login's rights or whether the server process is running; the self-hosted stack uses it for the worker container, whose process exits on any failure. For web, use GET /ready instead.

Server flags ​

text
      --role <ROLE>  Which parts to run (when no command is given); comma-separated, e.g. `worker,scheduler` [default: all] [possible values: web, worker, scheduler, all]

See Process roles for what each role runs and which connections and secrets it refuses or needs. The client commands (orbit login, orbit logout, orbit kernel ... and one per module operation) are in the API reference.

Kubernetes ​

With the Helm chart (deploy/helm/orbit, see deploy/README.md), the operator commands run in the toolbox pod, the only pod besides the migration Jobs that holds the owner URL (ORBIT_MIGRATION_DATABASE_URL) and ORBIT_AUDIT_KEY. It is off by default; turn it on for the task and off again afterwards. Turning it off removes the pod, not the credential: the Secret orbit-migrations that holds it stays for the life of the release and survives helm uninstall (see deploy/README.md).

bash
helm upgrade orbit deploy/helm/orbit --reuse-values --set toolbox.enabled=true
kubectl exec deploy/orbit-toolbox -- orbit tenant provision --org-id <id> --name "Acme" --module hello
helm upgrade orbit deploy/helm/orbit --reuse-values --set toolbox.enabled=false

(Names assume the release is called orbit; otherwise they are <release>-orbit-....)

The toolbox never holds ORBIT_DATA_KEY. Commands that need it read it from standard input, so it stays off command lines, process lists and the pod spec:

bash
# orbit keys rotate (and orbit keys destroy, the same way)
printf '%s\n' "$KEY" | kubectl exec -i deploy/orbit-toolbox -- bash -c \
  'IFS= read -r ORBIT_DATA_KEY && export ORBIT_DATA_KEY && exec orbit keys rotate --tenant <tenant id>'

To change the master key (the steps of orbit keys rewrap):

  1. Put the new key in ORBIT_DATA_KEY and the old one in ORBIT_DATA_KEY_PREVIOUS of the orbit Secret (secrets.orbit.existingSecret), then restart:

    bash
    # printf is a shell builtin, so the keys stay off process lists; kubectl reads stdin.
    printf '{"stringData":{"ORBIT_DATA_KEY":"%s","ORBIT_DATA_KEY_PREVIOUS":"%s"}}' "$NEW" "$OLD" \
      | kubectl patch secret <orbit secret> --type merge --patch-file /dev/stdin
    kubectl rollout restart deploy/orbit-web deploy/orbit-worker

    Do not change the key through helm upgrade --set secrets.orbit.dataKey=...: Helm keeps every revision's values in its release Secrets, so the old key would stay readable in the namespace (helm get values --revision N) and, with an older database backup, unseal every field the rotation meant to protect. If the release was installed with inline secret values, move to existingSecret first, and prune the old revisions (deleting the sh.helm.release.v1.orbit.v<N> Secrets, or --history-max) once the rewrap is done.

  2. Run the rewrap with both keys, new first, until it succeeds:

    bash
    printf '%s\n%s\n' "$NEW" "$OLD" | kubectl exec -i deploy/orbit-toolbox -- bash -c \
      'IFS= read -r ORBIT_DATA_KEY && IFS= read -r ORBIT_DATA_KEY_PREVIOUS &&
       export ORBIT_DATA_KEY ORBIT_DATA_KEY_PREVIOUS && exec orbit keys rewrap'
  3. Remove ORBIT_DATA_KEY_PREVIOUS (kubectl patch secret <orbit secret> --type json -p '[{"op":"remove","path":"/data/ORBIT_DATA_KEY_PREVIOUS"}]') and restart web and worker the same way.

The sidecar's operator scripts run in its own pods, like the compose commands: kubectl exec -i deploy/orbit-auth -- node src/rotate-key.ts retires the JWT signing key now, and printf '%s\n' "$EMAIL" | kubectl exec -i deploy/orbit-auth -- node src/clear-throttle.ts clears an email's sign-in limits.

orbit health is the worker and scheduler pods' liveness probe; web uses GET /health (liveness) and GET /ready (readiness).

Orbit by SkySync Tech. Licensed under AGPL-3.0.