How-to guide / Start and inspect a Kix project
Keep clusters on different versions of Kix
These docs describe Kix's main branch, which can include changes not yet released. Read the docs for the latest release.
By default, every cluster in a project uses the kix input in flake.nix, so
kix upgrade upgrades all clusters together. To upgrade staging first and
keep prod on its current version until you are ready, add a second Kix library
input to flake.nix and map each cluster to an input in the [versions] table
of kix.toml.
Add a second input and [versions]
Section titled “Add a second input and [versions]”Suppose your project uses Kix 0.12.3 and defines two clusters, staging and
prod (the version numbers on this page are examples). Every version of Kix in
the project must support [versions] (Kix 0.10.0 or later); earlier versions reject versions as an
unknown setting in kix.toml.
Every machine that runs kix for this project, including CI, also needs an
installed Kix on PATH that supports [versions] (run kix self upgrade to
update it). The Kix you start is what selects the version for each cluster. A
Kix from before [versions] always selects the version pinned by input kix,
and that version then refuses any cluster on another input because its Kix
library does not match.
First, add a second Kix library input (such as kix-stable) to flake.nix with
the same URL and tag as kix. Leave outputs unchanged. mkFlake still reads
inputs.kix, and Kix swaps in kix-stable automatically when building clusters
assigned to it:
1{2 inputs.kix.url = "github:kix-run/kix/v0.12.3";3 inputs.kix-stable.url = "github:kix-run/kix/v0.12.3";4
5 outputs = inputs: inputs.kix.lib.mkFlake {6 inherit inputs;7 clusters.staging = ./clusters/staging.nix;8 clusters.prod = ./clusters/prod.nix;9 };10}Next, add a [versions] table to kix.toml listing every cluster in the
project. List the clusters you want to upgrade first under kix, and the
clusters you want to keep on Kix 0.12.3 under kix-stable:
1[versions]2kix = ["staging"]3kix-stable = ["prod"]Version numbers stay in flake.nix and flake.lock. Once [versions] is set
in kix.toml, every cluster in flake.nix must appear under one input, and
kix must always pin the newest version of Kix in the project.
Track both files in Git so Kix sees them during evaluation:
❱ git add kix.toml flake.nix Then lock the new input in flake.lock:
❱ kix upgrade kix-stable Because kix-stable was not in flake.lock yet, Kix locks it without building
anything:
1Pinned input `kix-stable` to Kix 0.12.3 (updated flake.lock). Input `kix-stable` had no previous version in flake.lock, so Kix built nothing to compare.2Commit flake.lock and kix.toml.Commit kix.toml, flake.nix, and flake.lock before starting the upgrade.
Upgrade staging first
Section titled “Upgrade staging first”Preview and run kix upgrade with no arguments:
❱ kix upgrade --dry-run❱ kix upgrade kix upgrade upgrades only the kix input (for example, to Kix 0.14.2) and
builds only the clusters listed under kix:
1Upgrading Kix 0.12.3 -> 0.14.22Input `kix` in flake.nix, used by stagingkix-stable stays on v0.12.3 in flake.nix and flake.lock, so prod does
not change. If the upgrade includes a data migration that requires
kix upgrade --acknowledge, kix deploy staging is blocked until you
acknowledge it, while kix deploy prod still runs normally.
Review the manifest changes and release notes, commit flake.nix, flake.lock,
and kix-upgrade.json, and deploy staging:
❱ kix deploy staging Check which version each cluster uses
Section titled “Check which version each cluster uses”List the clusters or run kix doctor to confirm each cluster’s version and
input:
❱ kix list clusters❱ kix doctor kix list clusters adds KIX and INPUT columns when [versions] is
present:
1 NAME KIX INPUT2 prod 0.12.3 kix-stable3 staging 0.14.2 kixkix doctor prints a line for each input:
1✓ Project uses Kix 0.14.2 (flake.lock)2✓ Input kix pins Kix 0.14.2, used by staging3✓ Input kix-stable pins Kix 0.12.3, used by prodWhen you run a cluster command such as kix check prod, kix plan prod, or
kix deploy prod, Kix looks prod up in [versions], runs Kix 0.12.3
(installing it if needed), and builds prod with the Kix library from
kix-stable. Clusters on different versions of Kix can also deploy to the same
Kubernetes cluster. If two of them deploy the same object while only one has
upgraded to revisions, see
Kix clusters on two versions of Kix
for how Kix keeps that shared object compatible until both upgrade.
Every cluster in the repository still shares flake.nix, kix.toml, and any
imported .nix modules, so keep shared modules compatible with both versions of
Kix until all clusters have upgraded.
Upgrade prod later
Section titled “Upgrade prod later”Once you are ready to upgrade the remaining clusters, choose either approach:
Upgrade every cluster on kix-stable together
Section titled “Upgrade every cluster on kix-stable together”Run kix upgrade with the input name:
❱ kix upgrade kix-stable Without --to, this upgrades kix-stable in flake.nix and flake.lock to
match kix (Kix 0.14.2), builds every cluster under kix-stable before and
after, and shows the manifest changes and release notes. Pass --to <version>
to upgrade kix-stable to an intermediate version instead.
Move one cluster at a time
Section titled “Move one cluster at a time”If multiple clusters share kix-stable (such as prod and eu) and you want
to upgrade one at a time, pass the cluster name:
❱ kix upgrade prod --to kix --to names the target input (which must appear in [versions], or be kix)
and defaults to kix when omitted. To move a cluster to a new input instead,
add inputs.<input>.url to flake.nix and <input> = [] to [versions] in
kix.toml, run kix upgrade <input> to lock it, and then run
kix upgrade <cluster> --to <input>. Kix builds prod on kix-stable, moves
prod to kix in kix.toml, rebuilds prod on kix, and shows the manifest
changes and release notes:
1Cluster `prod`, from input `kix-stable` to input `kix`2Moved cluster `prod` to input `kix` on Kix 0.14.2 (updated kix.toml)flake.nix and flake.lock stay unchanged. If prod fails to build on the new
version, Kix leaves prod under kix in kix.toml so you can fix the build
error and run kix upgrade prod --to kix again to finish.
Commit the changed files (flake.nix and flake.lock when upgrading an input,
or kix.toml when moving a cluster, along with kix-upgrade.json) and deploy
prod:
❱ kix deploy prod Keep or remove the second input
Section titled “Keep or remove the second input”Once kix-stable has no clusters left (kix-stable = []), you can leave it in
flake.nix and kix.toml for your next staged upgrade, or remove
inputs.kix-stable from flake.nix and delete kix-stable (or the whole
[versions] table) from kix.toml.