← Back to blog

kcore started as a hypervisor. The job was the one Proxmox and VMware already do: run virtual machines on hardware you own, with an API in front of it. Declare a guest, apply it, and have the host converge. That path is still there. Cloud Hypervisor runs the guests. A shared Ceph RBD image is how a VM moves between hosts.

The product moved under the guest. kcoreOS is the host, a NixOS system the controller installs and keeps. The same control plane that places a VM also brings the server up from the BMC, and it declares the services that run on the metal itself: OCI containers, a Kubernetes cluster, a ClickHouse cluster, and a PostgreSQL cluster. Those are host services on kcoreOS.

We are in the process of deploying this into production at a company whose private cloud still runs on Proxmox. That cutover is not finished. The rest of this post is what the platform actually does today, and how we test the controller before it is asked to hold someone else's estate.

What runs on the metal

One apply path covers the workloads. kctl, a YAML manifest, and the Terraform provider talk to the same controller API. A field the API accepts has to be expressible in all three. Where that is still incomplete, the docs say so. PostgresqlCluster is one of those gaps: kctl and YAML apply it, and there is no Terraform resource for the cluster yet. Single-node PostgreSQL has one.

Slurm is the same shape for batch jobs: declared on the hosts, compute nodes left to slurmd. MySQL is the same shape and is not built yet.

From a powered-off server to an approved node

A single lab machine still starts from the evaluation ISO. A rack does not. kcore Provisioning is a separate controller. It speaks gRPC on port 9091, keeps its own SQLite database, and hands a finished node to the cluster. Running nodes do not call it again after install. The operator guide is kcore Provisioning. The lab dashboard write-up is Manage a server fleet with kcore-provisioning.

The sequence for one server:

  1. Register the image. The controller downloads a kcoreOS image, checks the SHA-256, and marks it verified. An unverified image cannot be a boot target. Downloads are capped at 50 GB.
  2. Discover the machine from the BMC. Redfish returns CPU, memory, drives, NICs, serial number, and BMC firmware. The inventory key is the serial (on a Dell, the service tag) or any NIC MAC, so the MAC does not have to be typed in first.
  3. Check the disks. kcore-disk-verify runs inside the netboot image. It writes each drive, power-cycles, and reads the data back. Each drive gets a verdict. An optional wipe runs only after every drive has verified. A failed drive stops the run.
  4. Apply a machine profile. BIOS attributes, RAID volumes, and non-RAID mode. The plan compares the profile with what the BMC currently reports and lists only the differences. Applying the same profile twice changes nothing the second time. BIOS, RAID, and virtual media go through Dell iDRAC. Virtual media needs an iDRAC Enterprise or Datacenter licence.
  5. Set the boot target and power it on. The boot path is UEFI HTTP boot. There is no TFTP step. The BMC is told where to fetch the loader. The machine requests its own GRUB config by serial or MAC, then pulls the kernel and initrd of the verified image. The artifact server is HTTPS on 8443, plus a plain HTTP listener for firmware and BMCs that cannot do TLS. That listener belongs on an isolated VLAN: anyone on the provisioning network can read a boot config.
  6. Install and approve. The machine boots kcoreOS. kctl node install writes kcore to the disk. An operator approves the node with kctl node approve or in the dashboard. From there it is an ordinary cluster member.

Power is on, off, reset, and a one-time boot override over Redfish. IPMI covers BMCs that do not speak Redfish. A machine with no BMC at all, such as a ThinkCentre in our lab, gets a Wake-on-LAN packet to the stored MAC. DHCP and DNS for the networks the provisioner owns come from Kea and PowerDNS. Reservations reach Kea only after an explicit Apply.

Calls that destroy data require confirm: true: RAID configuration, BIOS attribute writes, and a disk check that includes a wipe. BMC credentials come from the controller environment. They are not stored on the machine record. The API authenticates with mTLS client certificates, falls back to a bearer token, checks roles, and writes an audit log. The same RPCs are tools on the MCP server. A call that changes a machine asks for approval before it runs.

The boot path is tested end to end on Dell PowerEdge T140 with iDRAC 9. Other Redfish BMCs get discovery, power, and boot control. The provisioner installs kcoreOS only. It does not update firmware, and the provisioning plane itself is one controller and one SQLite database.

A virtual-media boot, once the machine and image already exist:

grpcurl -plaintext -d '{"machine_id":"rack1-07","image_id":"kcoreos-0.7.0","boot_once":true,"restart":true}' \
  localhost:9091 kcore.provisioning.Provisioning/MountVirtualMedia

The controller is a distributed system

Each controller keeps its own SQLite database. Peers replicate by shipping mutation events. They do not share a disk. A controller's identity is the CN of its TLS certificate, kcore-controller-{host}, minted at install. The cluster CA is the trust root. There is no join token.

A second controller is installed with --run-controller and the address of the first. After it boots, its poller connects with mTLS, pulls GetReplicationEvents, and acknowledges with AckReplicationEvents. The first controller learns the second from that acknowledgement, stores it in controller_peers, and starts polling back. Replication is then bidirectional. Node agents and kctl keep an ordered list of controllers and move to the next one when the current one is unreachable. Resources carry a dc_id. If you omit it, the value is DC1.

Two paths keep the databases in step:

Merge rules depend on the kind of data:

A partition can leave two controllers with different views until they exchange events. Each controller keeps accepting writes on its own SQLite database, and peers converge when the partition heals. The model does not promise linearizability of every write across every controller. The scheduler still re-checks, at commit time, that the node exists, is approved, and has capacity. Conflicting desired placement is surfaced and blocks an unsafe apply.

That limit is concrete for PostgreSQL. Fencing a VM is an RBD blocklist before the guest moves. A wrong Patroni promotion is two primaries, and the second timeline is lost when they meet again. The cluster engine therefore re-reads the live leader before each step, and only one actor holds the failover lease. Two controllers must not each decide to promote.

Earlier write-up of the choice against Raft: Why we chose CRDTs over Raft for multi-DC replication.

Conflict resolution without an operator in the loop

Every replicated mutation is an envelope: opId, controllerId, dcId, logicalTsUnixMs, event type, resource key, and a few policy fields (policyPriority, intentEpoch, validity, safetyClass). Receivers dedupe on opId in replication_received_ops.

Two events for the same resource key are ordered by a total rank. Every controller computes the same winner:

  1. validity — valid beats invalid
  2. safetyClass — safe, then risky, then unsafe
  3. policyPriority — higher wins
  4. intentEpoch — higher wins
  5. logicalTsUnixMs — higher wins
  6. controllerId — string tiebreak
  7. opId — string tiebreak

The winner is written to replication_resource_heads. A head materializer projects that head into the domain tables (nodes, VMs, networks, security groups, SSH keys) and records how far it got in replication_materialized_heads, so a replay does not apply the same head twice.

The loser reaches a terminal state on its own. auto_accepted is the winner. auto_rejected is an invalid or simply losing safe intent. auto_compensated is an unsafe loser: the apply path inserts a row in replication_compensation_jobs with the loser event and a payload snapshot, and a background executor runs an idempotent correction before it marks the conflict resolved. Equal-timestamp cross-controller contenders are also logged in replication_conflicts. GetReplicationStatus reports unresolved_conflicts.

VM create has an extra gate. A reservation checks that the target node is approved, ready, and has capacity before the intent is persisted. A failure is classified as retryable or not, with a bounded retry budget. A background executor promotes failed_retryable rows to reserved when the node recovers, or escalates them to retry_exhausted. The status RPC reports that count separately from conflicts still in progress.

Operators inspect this. They do not routinely merge it by hand. kctl get conflicts lists the audit rows. kctl get replication-status --require-healthy is the scripted gate. The verdict we watch is zero_manual_slo_healthy. It goes false when compensation jobs are pending or failed, materialization is behind, an unresolved conflict is too old, or a reservation has failed. After adding a controller, the check is: both controllers list the same approved nodes, and that flag is true on each of them.

How this is tested

Rust already removes a class of bugs on every build: data races, use-after-free, null dereference, buffer overrun. The controller, the node agent, and kctl are safe Rust. That says nothing about a bad Nix string, a VM row whose node does not exist, or two controllers applying the same event in different orders. Those get four more layers. All four run in CI.

Example tests, then generated tests

Ordinary tests are scenarios. cargo test -p kcore-controller replication::tests covers merge, materialization, reservations, and trace export. Admin RPC tests cover monotonic acknowledgements. A heartbeat test checks that a node heartbeat appends an inventory snapshot to the outbox when replication is configured. NixOS VM tests boot a host and exercise the modules. These tell us one path worked.

proptest generates inputs and checks a property. It runs inside cargo test. It can miss a bug. It finds inputs nobody writes by hand.

Longer version, focused on why these two tools sit next to each other: Why we use proptest and Kani.

Kani, on a crate small enough to prove

Kani is Amazon's bounded model checker for Rust. It compiles to CBMC and explores every input inside a bound, so a passing harness is a proof for that bound. A passing proptest run is a few thousand samples.

The proofs live in kcore-sanitize, a crate with no dependencies outside std. Pointing Kani at the controller pulls SQLite, rustls, and tonic, and the translation alone takes long enough that the proof never becomes the expensive part. The harnesses are byte loops: .. path checks, and acceptance of a path implying the path is actually safe (non-empty, no NUL, no .. segment). String builders and parsers are proptest. CBMC either fails to finish on them or has to be cut down to a length so small the proof is meaningless.

The path harnesses take every 4-byte ASCII input. That is on the order of 4 billion states, and it finishes in seconds because the implementation is a flat byte scan. CI runs cargo kani -p kcore-sanitize from .github/workflows/formal-checks.yml on every pull request. The harness set stays this small on purpose. These proofs cover the sanitizer. Controller state is the next section.

TLA+ for controller state

The replication protocol is specified in TLA+ and checked with TLC, separate from the Rust. TLC explores interleavings: retries, reordering, a peer that is down, a partition that heals. Three product models live in specs/tla/ and run under make test-tla:

A further set under specs/tla/model/ covers the compensation executor, replication reservations, and a second reconcile and disk-layout model. make test-tla checks those too.

TLC checks the specification. The Rust is checked against that specification by a trace gate, make test-tla-trace. A controller test, replication::tests::export_replication_trace_fixture, writes a trace that includes reservation_status and compensation_status, and it processes one compensation job during export so the trace contains both queued and completed. scripts/test-replication-trace.sh compares the trace with the model's winner rule and its automatic terminal states. The suite includes a fixture that must pass and a fixture that must fail, so a checker that starts accepting bad traces fails the build. CI requires both the TLC run and the trace run.

bash ./scripts/soak-replication.sh repeats that set. The default is five iterations. It is a soak of the test suite, which catches a flaky checker. It is not a substitute for a cluster that has been partitioned on purpose.

The earlier, shorter version of this is How we test replication with TLA+.

What we leave to integration tests

Most of the tree is I/O: gRPC handlers, files, nixos-rebuild, the HTTP client that talks to Cloud Hypervisor's socket. Kani and TLA+ do not see those processes. The bugs there show up in the NixOS VM tests and in the controller tests that drive a real SQLite database. Parsing with serde, and flag handling in kctl, sit in the same bucket.

The Proxmox estate

A company that runs its private cloud on Proxmox is working through a production deployment of kcore. The work is in progress. Their guests, storage, and operating habits are still Proxmox. Moving them means an inventory, a decision per disk, and a cutover window their operators will accept. kcore-migrate inventories a Proxmox cluster and converts exported disks. It does not perform the cutover.

Proxmox already has an API and a UI. The reason to leave it, for this deployment, is the operating model on this page: the server is provisioned from the BMC, the host and the data services are one declarative apply, and the control plane is replicated across controllers and across datacenters with the checks above in front of every merge. That is the system we are putting into production. It is not in production yet.

Where to read the rest

Questions: team@tacconiconsulting.com.