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.
- Virtual machines. Cloud Hypervisor. Disks on the node (filesystem, LVM, ZFS) or on Ceph RBD. Live migration uses the shared RBD image. A failed host update boots the previous NixOS generation.
- Containers. OCI images through nerdctl, or Docker if that is what the node has. A container stays on the node you created it on, next to the VMs. Scheduling across nodes is a Kubernetes cluster. The runtime is a CLI wrapper, so this is early container support, with create, start, stop, inspect, and delete.
- Kubernetes. The cluster runs on kcoreOS. Cilium for the network, keepalived for an API VIP, volumes on LVM or ZFS. Day-2 includes dual-CA rotation, etcd backups, and CSI snapshots. See the Kubernetes guide.
- PostgreSQL.
kind: PostgreSQLis one database on one node, from the NixOS package.kind: PostgresqlClusteris Patroni: a primary, streaming standbys, and etcd voters, also on kcoreOS. The controller plans create, update, upgrade, and switchover. A host update waits for a safe Patroni switchover before it reboots that node. The rollout planner is a pure function. Before every step it re-reads who the leader is, because Patroni can fail over in the middle of the operation. - ClickHouse.
kind: ClickhouseClusterdeclares shards, replicas, and a ClickHouse Keeper ensemble on kcoreOS.kctl clickhouseplans, applies, scales, replaces a replica, upgrades, and deletes. A rolling change leaves one healthy replica of each shard up, and it leaves Keeper quorum intact. The dashboard and the MCP server cover the same resource.
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:
- 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.
- 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.
- Check the disks.
kcore-disk-verifyruns 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. - 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.
- 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.
- Install and approve. The machine boots kcoreOS.
kctl node installwrites kcore to the disk. An operator approves the node withkctl node approveor 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:
- Realtime. An RPC mutates the local database, appends an event to
replication_outbox, and sends it to peers. The peer validates the envelope, dedupes onopId, merges, and persists. - Anti-entropy. A background poller compares frontiers with each peer and pulls the missing range. If compaction has dropped that range, it asks for a snapshot of that scope and then re-checks referential integrity. CRDT merge rules do not help if the event never arrived.
Merge rules depend on the kind of data:
- Runtime observations are last-writer-wins registers: heartbeats, readiness, VM runtime state, a discovered IP. The field is the latest observation, and it changes constantly.
- Desired state is an OR-map of multi-value registers: VM spec, network spec, labels, SSH key associations. Two operators editing the same object at the same time should both still be visible. Silent overwrite is the bug.
- Deletes are tombstones with causal metadata. Garbage collection waits until every known peer has observed the tombstone frontier.
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:
validity— valid beats invalidsafetyClass— safe, then risky, then unsafepolicyPriority— higher winsintentEpoch— higher winslogicalTsUnixMs— higher winscontrollerId— string tiebreakopId— 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.
- Nix generation. The controller emits Nix that
nixos-rebuild switchevaluates as root. For any input string,nix_escapemust not leave a raw${, a raw quote, or a raw backslash that would break out of the string.sanitize_nix_attr_keymust emit only[A-Za-z0-9_-]. A VM name or an image path that contains"; malicious-code "must stay inside a Nix string literal. - Controller SQLite. About 256 randomised cases per property, on an in-memory database. A node round-trips through upsert and get. Two upserts of the same id leave one row. A second upsert with a new address updates that row in place. Inserting a VM whose
node_idis missing fails, which depends onPRAGMA foreign_keys=ON. After delete, the VM is gone from get, from placement lookup, and from list. Two identical heartbeats match in every column exceptlast_heartbeat. - PostgreSQL rollout. The planner is pure. A property over clusters of 1 to 5 members checks the rollout invariants, including that a step marked
@leaderis resolved from the leader observed at execution time. - The same style covers the RBAC matrix, certificate rotation, storage export paths, node registration, and Slurm rendering.
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:
ControllerNodeReconcile.tla— the controller and the node agent. Desired config versus applied config, node status (unknown,ready,rebuilding,unreachable), and a node that dies in the middle ofnixos-rebuildand returns with the previous generation. Safety: a reachable node converges, a node does not apply a config for a deleted VM, two applies to the same node are serialized. Liveness, under fairness: reconciliation resumes after a node recovers, and a controller crash does not orphan a VM whose desired state is already in SQLite.ControllerReplication.tla— one datacenter. Outbox, delivery, apply, resource heads, frontiers, conflicts. Invariants: one deterministic winner, no double-apply, and every conflict reaches an automatic terminal state.CrossDcReplication.tla— intra-DC replication versus the slower cross-DC anti-entropy. Convergence after a partition and rejoin, and no double-apply across DCs. A local TLC run of this model explored 206,280 distinct states out of 3,941,400 generated states, and reported no error.
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
- Why I built kcore — the original hypervisor reasons.
- Provisioning — Redfish, IPMI, HTTP boot, disk checks.
- Containers, Kubernetes, PostgreSQL.
- Roadmap — what is shipped, including ClickHouse on kcoreOS, and what is still planned.
- CRDTs, TLA+, proptest and Kani.
Questions: team@tacconiconsulting.com.