Host & kcore upgrades
Not Kubernetes. This page rolls kcoreOS nodes to a kcore release. Prefer changing spec.version on the Cluster manifest (or kcore_cluster.version). kctl update version set, deprecated kcore_cluster_version, and hand-written ClusterUpdate / kcore_cluster_update still work. Kubernetes uses only KubernetesCluster / kcore_kubernetes_cluster. See Kubernetes version.
kcore nodes run NixOS. A release is a git tag, vX.Y.Z. You tell the controller which tag the cluster should run. It updates one canary node first, watches it, and then updates the others one at a time. A node that does not come back healthy goes back to the generation it ran before. Guests are not touched by the update itself. With drainVms they are migrated off a node before it reboots.
Set the cluster version
Bump version on the Cluster and apply. The controller stores the desired record and starts a canary rollout when nodes are off-version. Changing only update.reboot updates the stored policy and touches no node.
# Same as editing the Cluster manifest, then:
kctl update version set v0.8.3 --drain-vms
kctl update version set v0.8.3 --drain-vms --reboot # force BOOT activation
kctl update version set v0.8.3 --dry-run
kctl update version get
kind: Cluster
metadata:
name: prod
spec:
version: v0.8.3
update:
reboot: false
drainVms: true
soak: 1h
canaryNode: node-105
nodes:
- name: node-107
address: 192.168.40.107
osDisk: /dev/sda
controller: true
Apply: kctl apply -f cluster.yaml. Apply does not wait for the soak.
Showing Terraform examples. Provider source is kcorehypervisor/kcore, version 0.8.3.
resource "kcore_cluster" "prod" {
name = "prod"
version = "v0.8.3"
certs_dir = "${path.module}/certs"
update {
reboot = false
drain_vms = true
}
node {
name = "node-107"
address = "192.168.40.107"
os_disk = "/dev/sda"
controller = true
}
}
The controller does this, in order:
- Resolves the tag with
nix flake metadatain--flake-ref(defaultgithub:kcorehypervisor/kcore). An unknown tag is refused. - Reads the version and the controller database schema the tag declares. The version must match the tag. A tag whose controller cannot read this database is refused. Tags cut before this feature carry no such declaration and are refused too.
- Compares the tag with the version each node reports. Nodes already on it are left alone. The answer is
upgrade,downgrade,mixed, orunchanged. - Starts a ClusterUpdate named
version-vX-Y-Z. Setting the same tag again while it runs returns that update. Another tag is refused until it finishes or is cancelled.
Downgrade is the same command with a lower tag. An air-gapped site resolves tags against a mirror with --flake-ref git+https://git.example/kcore. Nodes still fetch build inputs from cache.nixos.org until signed update bundles ship.
Canary
The first node of a rollout is the canary. It updates like any other node and then soaks: it stays on the new version while the rest of the cluster waits. While it soaks, the controller compares it with the other nodes on every reconcile:
- It must still run the target version. A node that went back or rebooted into the old generation fails.
- It must keep sending heartbeats while other nodes do.
- Its share of
autoStartguests that are not running must not exceed the others’ by more than 10 percentage points. - Its node agent must not fail more of the controller’s calls than the other agents do, by more than 10 percentage points and at least 5 failures.
- If it hosts Ceph OSDs, their median commit latency over the last 15 minutes must stay below twice that of the other OSDs, or 20 ms above it, whichever is larger.
The first five minutes are not judged, so guests can start and Ceph can settle after the reboot. A failed comparison fails the canary and rolls it back. Nodes not started are cancelled. If the soak ends healthy, the rest update one at a time. If there is nothing to compare against, the canary waits in awaiting_promotion and you decide:
kctl update cluster get version-v0-7-0 # the canary and the reason
kctl update cluster promote version-v0-7-0 # continue with the other nodes
kctl update cluster cancel version-v0-7-0 # stop. The canary keeps the update
kctl update cluster rollback version-v0-7-0 # roll the canary back
promote also ends a soak early. It needs the cluster-admin role.
The canary is, in order: the node named with --canary, a node labelled kcore.io/update-canary=true, or the first node in rollout order. A node that runs a controller is not picked unless every node does. Controllers update last. A one-node rollout has no canary.
The soak lasts one hour, or 24 hours when the release moves NixOS to a new release. Change it:
kctl update version set v0.8.2 --soak 4h --canary node-b
kctl update version set v0.8.2 --no-canary
--soak takes 90s, 45m, 2h, 1d, at most 7 days.
One node, one transaction
The rollout stops at the first node that fails. Nodes not started are cancelled, nodes already updated stay on the new version, and the failed node is left on, or put back on, its previous generation. Set the previous tag to move the rest back.
On each node:
- Prepare. The node copies
/etc/nixosaside, writes the release flake, and builds it. It checks that the lock pins the commit the controller resolved. A failed build changes nothing. - Switch, when the kernel and every VM unit are unchanged. The new flake files go into
/etc/nixos, the old ones toprevious/, and a guard timer is armed. A failed switch makes the guard restore the old files and switch back at once. The agent confirms the switch after its checks pass three times in a row. If it never does, the guard switches back after 15 minutes. - Boot, when the kernel or a VM unit changed. The new generation is staged as a one-shot boot entry, with the running one still the default until the new one is confirmed. With
drainVmsthe controller migrates the guests off first and then reboots the node. - After the reboot,
kcore-boot-confirmwaits for the node agent (and the controller, where it runs) to stay up. If it does, the new generation becomes the default. If not within the timeout, the node records why and reboots into the previous generation. A kernel that panics or hangs never reaches the check. systemd-boot falls back to the previous entry because the new one was only a one-shot.
None of this needs the controller to be reachable while a node reboots, which is what edge and air-gapped nodes need. A node that does not return on the staged generation within 30 minutes is told by the controller to roll back. Database schema changes run inside the controller and are reversed before a controlled rollback when the step is reversible.
A 0.6.x controller has no update version command and refuses canary. Move a 0.6.x cluster to 0.7.0 once with a hand-written ClusterUpdate that names the commit of the v0.7.0 tag. After that, kctl update version set works. See What’s new in 0.8.2.
Hand-written rollouts
A kind: ClusterUpdate manifest still works for scoped rollouts and for updateKind: nixpkgs (move a tested OS pin only). The selector decides scope:
selector.allNodes: truefor the whole cluster, optionally with labels or a datacenter.selector.controllersOnly: truefor controllers.selector.nodeIds: ["<uuid>", …]for one or a few nodes.
kctl update cluster plan -f rollout.yaml
kctl update cluster apply -f rollout.yaml
kctl update cluster get my-update
kctl update cluster list
kctl update cluster approve my-update # when approvalPolicy is manual
kctl update cluster cancel my-update
kctl update cluster rollback my-update
kctl update cluster reboot my-update --node <node-id>
kind: ClusterUpdate
metadata:
name: my-update
spec:
target:
version: "0.8.2"
flakeRef: github:kcorehypervisor/kcore
flakeRev: "<full-git-sha>"
selector:
allNodes: true
strategy:
strategyType: canary
canarySoakSeconds: 3600
canaryNode: node-b
drainVms: true
activation:
mode: auto
approvalPolicy: manual
updateKind: kcore
Reboot stays kctl update cluster reboot. Destroy cancels the rollout.
resource "kcore_cluster_update" "os" {
name = "my-update"
version = "0.8.2"
flake_ref = "github:kcorehypervisor/kcore"
flake_rev = "<full-git-sha>"
all_nodes = true
strategy = "canary"
canary_soak_seconds = 3600
canary_node = "node-b"
drain_vms = true
activation = "auto"
update_kind = "kcore"
approval = "manual"
}
strategyType is one-at-a-time or canary. batch and per-dc are refused. With approvalPolicy: manual the controller waits for kctl update cluster approve before it rolls. The phase is pending, rolling_out, awaiting_promotion, succeeded, or failed. Each node row shows its own step and error.
Dashboard
The Release page is the same operation with a form: release tag, canary node, soak, No canary, Drain VMs, Dry run, and a Promote canary button. The Cluster updates page lists every rollout and its nodes. See Dashboard.
Before you start
- Take a Vault backup of the VMs that matter. See kcore Vault.
- Run with
--dry-runfirst. It prints what each node would do. - Keep at least one spare node’s worth of capacity if you use
drainVms, because guests move while a node reboots. - Update controllers last, and never all at once. The rollout does this for you.