# `upgrade`

`kix upgrade` upgrades a project, a Kix library input, or a single cluster to a
newer version of Kix. It builds the affected clusters with their current
version, updates the version pin or cluster assignment, and builds those
clusters again. Then it compares the two builds and lists the release notes
that apply.

`kix upgrade` runs in the Kix version you invoke directly, even when
`flake.lock` pins another version. For each version it tests, it installs that
version of Kix if needed and runs the build with it. It does not contact any
cluster.

:::note
This page is hand-maintained from `cli/kix-cli/src/cli.rs`,
`cli/kix-cli/src/cli/project.rs`, and `cli/kix-cli/src/commands/upgrade/`.
When flag definitions or behavior change in the Rust source, update this page
in the same change.
:::

## Synopsis

```text
kix upgrade [NAME] [--to <VERSION or INPUT>] [--dry-run]
kix upgrade --acknowledge <ID>...
```

## Arguments and flags

| Argument or flag | Default | Description |
| --- | --- | --- |
| `[NAME]` | `kix` | Optional. In projects with a `[versions]` table in [`kix.toml`](/docs/reference/kix-toml/#the-versions-table), an input name from `[versions]` (or `kix`) or a cluster name. Projects without `[versions]` accept only `kix` (or no name). |
| `--to <VERSION or INPUT>` | `latest` for `kix`; the `kix` input's version for another input; `kix` for a cluster | When upgrading an input, sets the target version: an exact release (`0.10.2`), a full prerelease (`0.11.0-rc.1`), a minor series (`0.10`, choosing its newest release), or `latest` (the newest non-prerelease). Inputs with no locked version or no clusters are [pinned without building](#pin-a-project-that-has-no-version). When `NAME` is a cluster, `--to` names the target input, which must appear in `[versions]` (or be `kix`). |
| `--dry-run` | `false` | Print what the upgrade would do and the release notes that apply, and change nothing. |
| `--acknowledge <ID>...` | none | Acknowledge a change to stored data by its id or name, so that `kix deploy` goes ahead. Does nothing else. |

`kix upgrade` has three forms:

| Command | What it does |
| --- | --- |
| `kix upgrade` | Upgrades the `kix` input to the newest release (or `--to`). Builds every cluster in the project, or only the clusters under `kix` when `kix.toml` defines `[versions]`. |
| `kix upgrade kix-stable` | Upgrades the `kix-stable` input to match `kix` (or `--to <VERSION>`), and builds only the clusters under `kix-stable`. Also locks a new input not yet in `flake.lock`. |
| `kix upgrade prod --to kix` | [Moves the cluster `prod`](#move-a-cluster-between-inputs) to the `kix` input in `kix.toml`. `--to` names an input in `[versions]` (or `kix`, the default when omitted). |

An input other than `kix` cannot advance past `kix`. When `--to` names a newer
version than `kix` pins, Kix changes nothing and exits `1`:

```text
Cannot upgrade input `kix-stable` to Kix 9.3.0: input `kix` pins Kix 9.2.0, and `kix` must pin the newest version in the project.
No project files were modified.
Next: run `kix upgrade` to upgrade `kix` first.
```

If an earlier upgrade stopped unfinished (after a build failure or a pending
manual edit), running a different `kix upgrade` command fails and prints the
command needed to finish that upgrade.

## The version the project uses

`kix upgrade` reads the version the project is on from the tag of the `kix`
input in `flake.lock`, such as `v0.10.0`. When `--to` names that version, it
prints this, fetches nothing, and exits `0`:

```text
Already on Kix 0.10.0. Nothing to upgrade.
```

Without `--to`, when the newest release is not newer than the project's
version, it prints this and exits `0`:

```text
Already on the latest Kix release (0.12.1). Nothing to upgrade.
```

`kix upgrade` does not move a project to an older version. When `--to` names
an older version, or a minor whose newest release is older, it changes no
files and exits `1`:

```text
Cannot move this project to Kix 0.10.0-rc.2: it is on Kix 0.10.0-rc.3, and `kix upgrade` only moves a project to a newer version.
No project files were modified.
Next: to go back to Kix 0.10.0-rc.2, restore flake.nix and flake.lock from a commit that pinned it.
```

## Pin a project that has no version

A project or input has no pinned Kix release when `flake.lock` is missing, when
an input in `flake.nix` is not in `flake.lock` yet, when the input URL has no
tag (such as `github:kix-run/kix`), or when the input tracks a branch or commit.
With no previous release to build and compare against, `kix upgrade --to 0.10.0`
(or `kix upgrade <input>`) pins the input without building. Plain `kix upgrade`
pins `kix` to the newest release. Inputs in `[versions]` with no clusters are
likewise pinned without building.

Kix writes `v0.10.0` into the input's URL in `flake.nix` when needed, adding a
tag or replacing a branch or commit, and creates or updates `flake.lock`
without building:

```text
Pinned the Kix library to 0.10.0 (updated flake.nix, flake.lock). This project's flake.lock pinned no version of Kix before, so Kix built nothing to compare.
Commit flake.nix and flake.lock.
```

A local folder has no versions, so Kix cannot pin it:

```text
Input `kix` points to the local folder `../kix`, which has no release tags. Set `inputs.kix.url` in flake.nix to a release tag such as `github:kix-run/kix/v0.10.0`.
```

Kix matches each `url` attribute in `flake.nix` to its input
(`inputs.<name>.url = "..."`, or `url = "..."` inside `<name> = { ... }`) and
updates only the target input's URL, leaving other inputs untouched even when
they point to the same repository and tag. If `flake.nix` has multiple matching
URLs and Kix cannot tell which input owns them, Kix changes nothing, prints the
matching lines, and asks you to edit the URL yourself. With `--dry-run`, Kix
prints what it would pin and changes nothing.

## Release notes

Every release of Kix publishes structured release notes beside its release
archives, as `kix-<version>-changes.json`, listed in the release's signed
`SHA256SUMS`. `kix upgrade` fetches the notes of every release after the
project's version up to the target and checks each file against
`SHA256SUMS`. A release made before structured release notes existed has
none, and the first run of an upgrade says so:

```text
Note: Kix 0.9.1 has no release notes; see CHANGELOG.md.
```

`kix upgrade --dry-run` lists every breaking, security, and upgrade note in
the range, and every release that every cluster must deploy, grouped by what
you must do. Added, changed, and fixed notes are counted. It changes
nothing:

```text
Kix 0.10.0 -> 0.12.1 (preview, no files changed)

6 changes between 0.10.0 and 0.12.1:
  * package used in this project (6 clusters)

  Config changes required (will fail the build until updated):
  * [K0003] caddy (0.11.0): `replicaCount` was renamed to `replicas`.
    [K0005] echo-server (0.11.0): `port` was renamed to `servicePort`.

  Behavior & data changes (builds cleanly, requires review before deploy):
    [K0009] (0.11.0): Cluster-wide default network policy mode now drops
      unmatched egress traffic in namespaces with at least one workload.
  * [K0007] harbor (0.12.0, moves stored data): Registry blob metadata moved
      to v2 layout; existing PVCs are migrated in place on first start.
      Requires `kix upgrade --acknowledge K0007` before `kix deploy`.

  Security fixes (builds cleanly, recommended for this upgrade):
  * [K0008] caddy (0.11.2, CVE-2026-4102): Fixes HTTP/2 CONTINUATION frame
      flood.
      Without upgrading: Set `caddy.http2 = false` in the cluster.

  Notes:
  * [metrics-port] caddy (0.11.2): Admin metrics endpoint now binds to
127.0.0.1:2019 by default.

  14 minor feature and bugfix changes between 0.10.0 and 0.12.1 are not shown (see CHANGELOG.md).

`kix upgrade` will stop for [K0003], [K0005] until you make the config changes above.
Next: run `kix upgrade`.
```

A note names packages, and Kix sees only the instance names a cluster uses
(from `kix list packages <name>`, run with the project's current Kix). So Kix cannot tell which notes affect a project. It lists them all,
and marks with `*` a note whose package name equals the name of an instance
in use. An unmarked note can still affect an instance with another name.
When the current Kix is not installed, the preview marks nothing. When the
range has no breaking, security, or upgrade notes, it says
`No breaking, security, or upgrade notes between 0.10.0 and 0.12.1.`

## What a run does

1. Builds every cluster on the target input (or every cluster in the project
   when `kix.toml` has no `[versions]` table) with its current Kix version, and
   exports manifests with Kix annotations into
   `~/.cache/kix/upgrade/<project>/before/` (or a subdirectory for that input).
   If any cluster fails to build, `kix upgrade` exits `1`; fix the build on the
   current version first.
2. Pins the input to the target version, installs that Kix release, and builds
   those clusters again. Pinning updates the tag in the input's URL in
   `flake.nix` (such as `github:kix-run/kix/v0.9.1` or `?ref=refs/tags/v0.9.1`)
   and locks it in `flake.lock`. Kix matches each `url` attribute in
   `flake.nix` to its input (`inputs.<name>.url = "..."`, or `url = "..."`
   inside `<name> = { ... }`) and updates only the target input's URL. If
   `flake.nix` has multiple matching URLs and Kix cannot tell which input owns
   them, Kix changes no files, prints the matching lines, writes `edit-needed`
   to `kix-upgrade.json`, and exits `3` before installing the target; update the
   input's URL yourself and run the command again. If Nix cannot lock the new
   tag, or the project evaluates with a mismatched Kix library version, Kix
   restores `flake.nix` and `flake.lock`, prints the error, and exits `1` or
   `3`.
3. When a cluster does not build with the target, takes one minor release at
   a time: the newest patch of each minor after the project's, ending with
   the target. A project on a prerelease, such as `0.9.0-rc.1`, takes the
   newest release of its own minor first. It stops at the first release a cluster does not build with,
   prints the end of each error and that release's matching config changes,
   keeps each cluster's full build output in a log file, leaves the project
   pinned to that release, and exits `1`:

   ```text
   Building 6 clusters with Kix 0.12.1... failed (dev)
   Stepping one minor release at a time (0.11.2 -> 0.12.1):
   Building 6 clusters with Kix 0.11.2... failed (1 of 6 failed: dev)

     Cluster dev:
       error: The option `packages.experimental.caddy.replicaCount` does not exist.
       Full build log: ~/.cache/kix/upgrade/<project>/logs/0.11.2/dev.log

     Matching change in Kix 0.11.0:
       [K0003] caddy: `replicaCount` was renamed to `replicas`.

   Stopped at Kix 0.11.2 (step 1 of 2 toward 0.12.1).
   flake.nix and flake.lock are pinned to 0.11.2 so you can fix this step first.
   Next: fix the error above, then run `kix upgrade` to continue to 0.12.1.
   ```

   Fix the errors against that
   release, then run `kix upgrade` again. The next run reuses the builds from
   step 1 and the package list made then, tries that release again, and
   continues to the version the first run aimed at, such as the release
   candidate it named with `--to`. So does a run after an interruption, since Kix writes
   `kix-upgrade.json` before it first pins the project. If the cached builds
   from step 1 are missing, Kix stops with an error. Delete `kix-upgrade.json`
   and run `kix upgrade` again; the comparison then starts from the version
   the project is pinned to now.
4. Compares the first build with the last, cluster by cluster, and prints the
   objects added, removed, and changed. Clusters that changed the same way
   are printed together, with `+`, `~`, and `-` for added, changed, and
   removed objects. A change is marked `[review: <Kind>]` when the object is a
   Secret, Role, ClusterRole, RoleBinding, ClusterRoleBinding,
   NetworkPolicy, CiliumNetworkPolicy, CiliumClusterwideNetworkPolicy, or
   Certificate, or an Ingress or Gateway whose TLS settings changed.
5. Searches the files git tracks in the project for each command or flag a
   release note says was removed or changed, and prints `file:line` for each.
   It skips `flake.lock`, `CHANGELOG.md`, `changes/`, and files over 1 MB.
6. Removes each version of Kix it installed only to build with, keeping the
   version the project used and the version it is now pinned to. It says so
   only with `-v`.
7. Writes `kix-upgrade.json` in the project, and ends with what to review
   before you deploy:

   ```text
   Upgraded to Kix 0.12.1, but review before deploying:
1. 3 Secrets changed in cluster prod (Secret/harbor-core@registry,
   Secret/harbor-exporter@registry, Secret/harbor-jobservice@registry).
2. 5 objects changed in clusters dev, prod; read the changes above, or run
   `kix plan <cluster>`, before you deploy.
3. [K0007] moves stored data in harbor. Once you are ready for the
   migration, unblock deploy with:
          kix upgrade --acknowledge K0007
   ```

   Any object that changed in any cluster is on this list, and the run
   exits `3`. Only when no object changed and nothing needs a review does it
   end with `Upgraded to Kix 0.12.1. Ready to deploy.` and exit `0`.

When a release between the project's version and the target has a change
that every cluster must deploy before it upgrades further, the upgrade ends
at the newest patch of that release's minor, and exits `3`:

```text
Upgraded to Kix 0.11.2, but review before deploying:
1. Kix 0.11.0 must be deployed to all clusters before continuing to 0.12.1
   (`kix deploy` on 0.12.1 will refuse any cluster still on 0.10.0).
     flake.nix and flake.lock are pinned to 0.11.2.
Next: commit this 0.11.2 step and deploy every cluster with `kix deploy <cluster>`, then run `kix upgrade` to continue to 0.12.1.
```

[`kix deploy`](/docs/reference/cli/deploy/#required-stops) refuses a
cluster that would skip the release.

## Move a cluster between inputs

In a project with a `[versions]` table in
[`kix.toml`](/docs/reference/kix-toml/#the-versions-table),
`kix upgrade <cluster> [--to <input>]` moves one cluster from its current input
to another input listed in `[versions]` (or `kix`, the default when `--to` is
omitted).

Kix builds the cluster on its current input's version, moves the cluster to the
target input in `kix.toml`, rebuilds the cluster on the target input's version,
compares the two builds, and shows the release notes between the two versions.
`flake.nix` and `flake.lock` stay unchanged. Output includes:

```text
Cluster `west`, from input `kix-stable` to input `kix`
Moved cluster `west` to input `kix` on Kix 9.2.0 (updated kix.toml)
```

When nothing changed and nothing needs review, the run ends with
`` Moved cluster `west` to Kix 9.2.0 (input `kix`). Ready to deploy. ``
and exits `0`. When an object changed or a note requires review, it ends with
`` Moved cluster `west` to Kix 9.2.0 (input `kix`), but review before deploying: ``
and exits `3`.

If the cluster fails to build on the new version, Kix leaves it listed under
the target input in `kix.toml` so you can fix the build, saves
`kix-upgrade.json`, and exits `1`:

```text
kix.toml now lists cluster `west` under `kix` (Kix 9.2.0) so you can fix the build.
```

Fix the build and run `kix upgrade west --to kix` again. Kix reuses the cached
baseline build and finishes the comparison.

Other rules when moving a cluster:

- **Target input in `[versions]`:** `<input>` must be listed in `[versions]`
  (an empty list such as `kix-next = []` counts), or be `kix`. An input present
  only in `flake.lock` is refused. To add a new version input, set
  `inputs.<input>.url` in `flake.nix` and `<input> = []` in `kix.toml`
  `[versions]`, run `kix upgrade <input>` to lock it, and then run
  `kix upgrade <cluster> --to <input>`.
- **Newer versions only:** A cluster can move only to an input that pins a
  newer version. Moving to an input on an older version is refused.
- **Same version or development input:** When both inputs pin the same version,
  or either input points to a local folder or branch, Kix updates `kix.toml`
  without building and notes why it skipped build comparison.
- **Required stops:** When a release between the two versions must be deployed
  first, Kix refuses the move without changing files and tells you to run
  `kix upgrade <from-input> --to <release>`, deploy, and then move the cluster.
- **Direct edits:** You can also edit `[versions]` in `kix.toml` directly. No
  upgrade review runs; use [`kix plan <cluster>`](/docs/reference/cli/plan/) to
  see what deploying will change.

## Changes to stored data

A change that moves or reinterprets stored data with no error goes into
`kix-upgrade.json`. Until someone acknowledges it, `kix deploy` blocks any
cluster that the upgrade built, prints the note, and shows the command to run:

```text
Deploy blocked: upgrade to Kix 0.12.1 includes an unacknowledged data migration.
No clusters were contacted.

  [K0007] (0.12.0, moves stored data):
    Registry blob metadata moved to v2 layout; existing PVCs are migrated in
    place on first start.

Next: once you are ready for this migration, run:
  kix upgrade --acknowledge K0007
Then run `kix deploy` again.
```

`kix upgrade --acknowledge K0007` records the acknowledgement in
`kix-upgrade.json`:

```text
Acknowledged K0007 in kix-upgrade.json. You can now run `kix deploy`.
```

`kix deploy --dry-run` and `kix plan` are not blocked.
Another `kix upgrade` also refuses until each change is acknowledged.

This check reads `kix-upgrade.json`, so it protects only a project that was
upgraded with `kix upgrade` and kept the file. A project whose pins were
moved by hand gets no refusal. Commit `kix-upgrade.json` with the upgrade.

## `kix-upgrade.json`

| Field | Meaning |
| --- | --- |
| `schema` | `kix.run/upgrade/v1` |
| `from`, `to` | The version the upgrade started from, and the version it moved to. |
| `requested` | The `--to` value the upgrade started with. Absent when it moved to the latest release. A run that resumes without `--to` uses it. |
| `input` | Optional. Flake input upgraded (omitted when upgrading `kix`), or target input when moving a cluster. |
| `cluster` | Optional. Cluster moved between inputs (omitted when upgrading an input). |
| `clusters` | Optional. Subset of project clusters built by this upgrade. |
| `status` | `done`, `fix-needed` (a build failed, or the run stopped part of the way), `edit-needed` (manual edit needed in `flake.nix` or `kix.toml`), `needs-person`, or `required-stop`. |
| `steps` | Each version the project was built with: `version`, `result` (`ok`, `failed`, or `started` for a step that stopped before it built), and `failed`, the clusters that did not build. |
| `records` | The ids (or names, for a note without an id) of the release notes that apply, by kind. |
| `dataChanges` | The changes to stored data: `reference`, `release`, and `body`. |
| `acknowledged` | The data changes someone acknowledged with `--acknowledge`. |
| `sensitiveChanges` | How many changed objects are sensitive. |
| `cliHits` | Each project line that uses a changed command or flag: `text`, `file`, `line`. |
| `before` | The directory of the builds made with the version the upgrade started from. |
| `packageIdsInUse` | Built-in package IDs installed across the project's clusters (such as `harbor` or `experimental/coredns`), reported by the Kix version the upgrade started from. Omitted when that version does not report package IDs or could not list packages. |

Programs that read the file must skip fields they do not know.

## Environment

| Variable | Effect |
| --- | --- |
| `KIX_RELEASE_SOURCE` | A site laid out like kix.run to fetch releases from, such as an internal mirror. See [`kix self`](/docs/reference/cli/self/#environment). |
| `XDG_CACHE_HOME` | The builds go under `$XDG_CACHE_HOME/kix/upgrade/` in place of `~/.cache/kix/upgrade/`. |

## Exit status

- `0` when the upgraded clusters build cleanly on the target version with no manifest changes or items requiring review, and on `--dry-run` or `--acknowledge`.
- `1` when the release index or release notes cannot be fetched or verified, a version cannot be installed, the input or cluster cannot be upgraded, or a cluster fails to build on its current version or a target version.
- `3` when the upgrade needs your attention: either the run paused for a manual edit to `flake.nix` or `kix.toml`, or the upgraded clusters built on the target version with items to review before deploying (manifest changes, sensitive resource changes, behavior or data migrations, or a required intermediate deploy).

:::tip[Use it in a task]
See [Upgrade a project to a new version of Kix](/docs/how-to/start-and-inspect/upgrade-a-project-to-a-new-kix/)
to upgrade every cluster together, or
[Keep clusters on different versions of Kix](/docs/how-to/start-and-inspect/hold-clusters-on-different-kix-versions/)
to upgrade staging before production.
:::