Skip to content

Local clusters

Two local cluster modes run the real node services directly from your checkout’s anastrod binary, so Rust changes deploy in seconds without rebuilding a full Nix image.

VM cluster (just cluster) KVM cluster (just kvm-cluster)
Topology NixOS VMs from nix/clusters/<name> (single or ha) 3 converged nodes (cp1–cp3) from nix/kvm-cluster/repo
Runtime QEMU (Hypervisor.framework on macOS, KVM on Linux) Docker containers with /dev/kvm (via Colima on macOS)
Database Standalone Postgres (single) or Patroni + etcd (ha) Patroni + etcd
Runs microVMs? No (no /dev/kvm in macOS QEMU VMs) Yes, with workspaces stored on RustFS on cp1
Best for Failover, backups, config apply, node API End-to-end threads, machines, and web UI

Requires an aarch64-linux Nix builder on macOS (nix-darwin’s nix.linux-builder), or KVM on Linux.

Terminal window
just cluster up ha # or `up single` (`ha` is default)
just cluster status # node ports and apid health
just ctl node status # anastroctl over iroh to every node
Command Action
just cluster up [name] Validate repo, cross-build anastrod/anastroctl, boot VMs, unseal, wait for apid
just cluster status Show node ports and apid health
just cluster deploy Rebuild anastrod and restart machined, apid, and relay on every node
just cluster ssh <node> [cmd] Open a root shell or run a command (e.g. just cluster ssh cp1 patronictl list)
just cluster console <node> Tail a node’s serial console
just cluster crash <node> Hard-kill a VM to test failover
just cluster start <node> Boot a stopped VM
just cluster down Power off VMs, keeping state
just cluster destroy Power off and wipe all state

just ctl <args> runs anastroctl from source pre-wired to the VM cluster’s client file and config repo:

Terminal window
just ctl whoami # this computer is enrolled as first admin
just ctl node services
just ctl cluster apply --dry-run
just ctl cluster backup status
just ctl account device list

Nodes are numbered alphabetically (cp1 → 1, etc.). Node n gets 192.168.1.n on the private VM subnet (192.168.1.0/24) and maps to localhost as:

Localhost port Target on node n
127.0.0.1:844n TCP apid HTTP (/healthz, /api/docs, UI)
127.0.0.1:745n UDP iroh endpoint
127.0.0.1:222n TCP Passwordless root SSH

In ha mode, each node runs its relay on 192.168.1.n:3340. Your Mac talks to VMs directly; the ha NixOS VM test exercises relay-only connections.

  • Cross-compiles anastrod and anastroctl (*-linux-musl via cargo zigbuild) into .data/dev (mounted inside every VM at /anastro-dev), copying web/dist if built. Only edits under nix/ rebuild VM images.
  • Seeds each node’s initial config with ANASTRO_CONFIG_SEED (later updates go through just ctl cluster apply), enrolls your computer’s device key as first admin, writes .data/cluster/anastroconfig.toml, and unseals nodes from secrets.age using nix/dev/age.key.

When adding new secrets to a dev cluster config:

Terminal window
cargo run -p anastroctl -- --identity nix/dev/age.key -C nix/clusters/<name> cluster bundle set <path>
just ctl cluster unseal --identity nix/dev/age.key -C nix/clusters/<name>

State lives in .data/cluster and .data/dev.

Requires Docker with /dev/kvm (on macOS, Colima with vmType: vz and nestedVirtualization: true) plus an aarch64-linux Nix builder.

Terminal window
just kvm-cluster up # build, boot cp1..cp3, unseal (or restart stopped nodes)
just kvm-cluster ui # open web UI signed in as your computer
Command Action
just kvm-cluster up Build binaries, UI, and node system; boot and unseal cp1–cp3
just kvm-cluster status Node status and apid health
just kvm-cluster ui Launch anastroctl ui against the KVM cluster
just kvm-cluster dev Vite HMR on http://localhost:7482 against a node’s apid
just kvm-cluster ctl <args> Run anastroctl against the cluster (e.g. ctl cluster host list)
just kvm-cluster deploy Rebuild anastrod, anastroctl, web/dist, and sidecar; restart services without stopping machines
just kvm-cluster shell <node> [cmd] Root shell or command inside a node container
just kvm-cluster crash <node> / start <node> Hard-kill or start a container
just kvm-cluster down / destroy Stop containers (keeping volumes) or wipe everything including .data/kvm-cluster

Because Colima forwards TCP but not UDP, anastroctl reaches each node via its relay on 127.0.0.1:335n (apid HTTP is on 127.0.0.1:845n).

State lives in .data/kvm-cluster and Docker volumes (anastro-kvm-nix plus one /var/lib volume per node). Re-running up after changes under nix/ updates the system while preserving state; config updates to a running cluster go through just kvm-cluster ctl cluster apply. Each node fits one default-sized machine (4 GiB RAM, 20 GiB disk). Because containers share Colima’s kernel, Patroni’s hardware watchdog is disabled here.