Skip to content
Install the CLI

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.

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:

flake.nix
{
inputs.kix.url = "github:kix-run/kix/v0.12.3";
inputs.kix-stable.url = "github:kix-run/kix/v0.12.3";
outputs = inputs: inputs.kix.lib.mkFlake {
inherit inputs;
clusters.staging = ./clusters/staging.nix;
clusters.prod = ./clusters/prod.nix;
};
}

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:

kix.toml
[versions]
kix = ["staging"]
kix-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:

my-project/
❱ git add kix.toml flake.nix

Then lock the new input in flake.lock:

my-project/
❱ kix upgrade kix-stable

Because kix-stable was not in flake.lock yet, Kix locks it without building anything:

Pinned 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.
Commit flake.lock and kix.toml.

Commit kix.toml, flake.nix, and flake.lock before starting the upgrade.

Preview and run kix upgrade with no arguments:

my-project/
❱ 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:

Upgrading Kix 0.12.3 -> 0.14.2
Input `kix` in flake.nix, used by staging

kix-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:

my-project/
❱ kix deploy staging

List the clusters or run kix doctor to confirm each cluster’s version and input:

my-project/
❱ kix list clusters
❱ kix doctor

kix list clusters adds KIX and INPUT columns when [versions] is present:

NAME KIX INPUT
prod 0.12.3 kix-stable
staging 0.14.2 kix

kix doctor prints a line for each input:

✓ Project uses Kix 0.14.2 (flake.lock)
✓ Input kix pins Kix 0.14.2, used by staging
✓ Input kix-stable pins Kix 0.12.3, used by prod

When 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.

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:

my-project/
❱ 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.

If multiple clusters share kix-stable (such as prod and eu) and you want to upgrade one at a time, pass the cluster name:

my-project/
❱ 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:

Cluster `prod`, from input `kix-stable` to input `kix`
Moved 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:

my-project/
❱ kix deploy prod

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.