# `plan`

`kix plan` runs the deploy pipeline with every write sent as `dryRun=All`, so
the apiserver answers for each object. It builds the cluster, reads the
running activation, computes the same plan `kix deploy` computes, and sends
each apply and prune delete as a dry run. Nothing is written, and no
Activation record is created or changed.

`kix deploy` makes the same plan before it asks for confirmation and prints
it, with field changes shown under `-v`. `kix deploy --dry-run` runs
`kix plan` with the same flags.

With `--read-only`, `kix plan` sends no writes at all, dry run or not. It
reads the live cluster with `get` and `list` and compares it with the build.
See [Read-only plans](#read-only-plans).

This page is hand-maintained. Check `cli/kix-cli/src/cli.rs`,
`cli/kix-cli/src/commands/plan.rs`, `cli/kix/src/plan/file.rs`,
`cli/kix-cli/schema/plan.schema.json`, and
`cli/kix-cli/schema/kixplan.schema.json` when in doubt.

## Synopsis

```text
kix plan <CLUSTER> [--prune | --skip-orphan-check] [--reconcile]
         [--force-conflicts] [--accept-migrations] [--offline]
         [--only <NAMESPACE/INSTANCE>]... [--operator-removed]
         [--bundle <FILE> [--deployed-bundle <FILE>]...]
         [-o text|markdown] [--out <FILE>]
         [--flake <FLAKE>] [--context <CONTEXT>]

kix plan <CLUSTER> --read-only [--bundle <FILE>]
         [-o text|markdown|json|yaml] [--detail plain|fields|manifests]
         [--out <FILE>] [--flake <FLAKE>] [--context <CONTEXT>]
```

| Argument or flag | Meaning |
| --- | --- |
| `<CLUSTER>` | Cluster name to build from the flake. |
| `--prune` | Plan the prune a `kix deploy --prune` would run: each orphan's delete is sent as a dry run. Without it, orphans are listed as kept. |
| `--skip-orphan-check` | Do not look for orphans, and plan no prune. Not with `--prune`. |
| `--reconcile` | Plan a re-apply of every resource, including those whose identity hash matches the running activation. |
| `--force-conflicts` | Plan the apply with forced field ownership. Fields another manager owns show as drift the deploy reverts instead of as conflicts. |
| `--accept-migrations` | Accept the stateful migrations the plan lists, so they do not count as a reason the deploy would stop. |
| `--only <NAMESPACE/INSTANCE>` | Preview deploying only this package instance and the instances and resources it depends on, matching [`kix deploy --only`](/docs/reference/cli/deploy/#deploy-one-instance-at-a-time). Repeatable. The plan shows only this step's changes, lists the selected and required instances, and counts the remaining changes in the build. Cannot be combined with `--prune` or `--read-only`. |
| `--operator-removed` | Preview a deploy that reclaims this Kix cluster from an uninstalled Kix operator. `kix plan` changes nothing on the cluster. Cannot be combined with `--out`, because `kix deploy --plan` reclaims the cluster before checking the saved plan and would reject it as out of date. Run `kix deploy <cluster> --operator-removed` without `--plan` instead. See [Take a cluster back from a removed operator](/docs/reference/cli/deploy/#take-a-cluster-back-from-a-removed-operator). |
| `--offline` | Take the previous activation from the local cache and connect to nothing. The plan compares the cached build with the new one, and every write-path check reads `not_checked`. See [Offline plans](#offline-plans). |
| `--read-only` | Read the live cluster instead of sending a dry run. See [Read-only plans](#read-only-plans). |
| `--bundle <FILE>` | Read the build from a bundle written by `kix bundle` instead of building from the flake. Not with `--offline`. |
| `--deployed-bundle <FILE>` | With `--bundle`, a bundle of a previously deployed build to use when that build is not in Kix's local store. Matched by the Activation record's identity hash. Repeatable. Not with `--read-only`. |
| `-o`, `--output` | `text` (default) or `markdown`. With `markdown`, progress lines go to stderr so stdout holds the Markdown alone. With `--read-only`, also `json` or `yaml` (the JSON document as YAML). Without it, `json` and `yaml` are refused: write a [plan file](#plan-file) instead. |
| `--detail <LEVEL>` | With `--read-only`, how much `json` and `yaml` say about each change: `plain` (default), `fields`, or `manifests`. See [`kix diff`](/docs/reference/cli/diff/#json-and-yaml). |
| `--out <FILE>` | Also write the plan to `FILE` as a [plan file](#plan-file), which [`kix deploy --plan`](/docs/reference/cli/deploy/#deploy-a-reviewed-plan) reads. The file is written beside `FILE`, read back, and only then renamed, so a file that would be refused never appears at `FILE`. The text or Markdown output is printed as well. |
| `--flake`, `--context`, `--override-input` | See [Global flags](/docs/reference/cli/global-flags/). |

The planning flags are the ones `kix deploy` takes, so a plan made with the
same flags is the plan the deploy runs.

## Deploy lock

`kix plan` reads the cluster's
[deploy lock](/docs/reference/cli/deploy/#the-deploy-lock) (`get` on
`activationheads.kix.run`) without waiting for or taking it. When another run
holds the lock, the plan shows who holds it, what it is doing, and how long
ago it renewed its lease. If more than 30 seconds have passed since the last
renewal (measured by this machine's clock), the plan notes that the lease has
expired, the holder has likely stopped, and the next command that changes the
cluster will take over the lock. While any run other than operator drift
repair holds the lock, the plan leaves out resources from earlier failed or
partial deploys and notes that omission. If your account may not `get`
`activationheads.kix.run`, `kix plan` skips the lock check, but it still needs
`list` on that kind (see [Permissions](#permissions)).

## Permissions

A dry run is authorised like the write it simulates, so `kix plan` needs the
permissions of the deploy it previews. A user who may only `get` and `list`
gets `forbidden` refusals. Use `kix plan --read-only` for a comparison that
needs only `get` and `list`.

`kix plan` reads the live state of every object in the build and every object
referenced by the cluster's [revisions](/docs/reference/annotations-crds-and-receipts/#packageinstancerevision)
to determine what the deploy will write (see
[How a deploy decides what to write](/docs/reference/cli/deploy/#how-a-deploy-decides-what-to-write)).
It sends one cluster-wide `list` request per resource kind, falling back to
individual `get` requests for any kind the account cannot list cluster-wide. If
the account can neither `list` nor `get` a kind, `kix plan` stops and reports
the missing permissions.

`kix plan` also requires `list` permission on `activationheads.kix.run` and
`packageinstancerevisions.kix.run` to see which objects each Kix cluster on the
Kubernetes cluster deploys. Without those permissions, planning stops
immediately.

## What it reports

| Section | Content |
| --- | --- |
| Field changes | For each object the dry run answered, the live object compared with the object the apiserver says the apply would produce. Server-maintained metadata and `status` are left out, and Secret values are not shown. A package the build comparison called unchanged becomes changed when the apiserver says it would change. |
| Writes the deploy would stop on | Field ownership conflicts, with the manager that owns each field; admission webhook denials; ValidatingAdmissionPolicy denials; validation errors; changes to immutable fields; RBAC refusals; missing namespaces and unknown kinds the build does not create; SOPS Secrets that do not decrypt; and refused prune deletes. |
| Objects being deleted | Objects this deploy applies that are already being deleted on the cluster (including objects that did not change in the build), showing when deletion started and any finalizers holding them. The deploy waits for each old object to be removed and then creates a new one from the build. Any object that may hold data, such as a PersistentVolumeClaim, carries a warning that the new object starts empty and keeps none of the old object's data. Shown as a warning; does not stop the deploy. |
| Prune | Each orphan and what the deploy does with it. See [Prune fates](#prune-fates). |
| Stateful migrations | Objects that hold data that the change removes from a stateful package and adds in their place. A deploy stops on them unless run with `--accept-migrations`. |
| Drift | Fields where the live object differs from the deployed build, the managers that own them live, and whether the deploy puts the deployed value back. |
| Not checked | Objects the dry run could not check. See [Objects not checked](#objects-not-checked). |
| Library warnings | The Kix library's warnings about the build, the same ones [`kix check`](/docs/reference/cli/check/#library-warnings) lists. Text output prints them to stderr while the cluster builds. |

Every refusal shows, not only the first. The dry run carries on past a
refused write and still tries the objects that depend on it, since nothing a
dry run writes persists.

No preview can say whether Pods start, pull their images, and pass their
probes, so `readiness` is always `not_checked`.

## Output formats

### Text

Before connecting, `kix plan` prints the kubeconfig context and API server URL
(for example, `Connecting to context prod (https://prod.example:6443)...`).
It then prints the same package-grouped plan as `kix deploy`, with every field
change shown.
A change that puts back a drifted field is tagged `(reverts drift)`. Below the
package list, summary lines count writes not caused by manifest changes in the
build: a `↻` line for objects modified by an interrupted deploy, missed by a
degraded deploy, or missing a recorded applied hash; a `↺` line for drifted
objects whose changed fields the deploy takes back; and a separate `↻` line for
objects with fields owned by another Kix cluster, which the deploy applies
without force. On the first deploy after upgrading to revisions, an `Upgrade:`
line counts the objects whose metadata Kix updates once.
After the packages come these sections, each only when it has something to
say:

- `The deploy would stop on N writes:`, one line per conflict, refusal, or
  refused prune delete, with the owning manager and fields or the
  apiserver's message.
- `N objects in the build are being deleted on the cluster`, one line per
  object showing when deletion started and any finalizers holding it, plus a
  second warning line when the object may hold data.
- `Drift:`, one line per drifted field with its live and deployed values,
  the managers that set it, and whether the deploy reverts it.
- `Prune:`, objects that left the build and stay on the cluster
  because another Kix cluster deploys them or they changed since they were
  read.
- `Prune: N deletes will wait for finalizers or ongoing deletion:`, one line
  for each pruned object that has finalizers or is already being deleted,
  showing any `deletionTimestamp` and finalizers. When a custom resource's
  kind declares a `controller` (on `scope.mkCRD` or `scope.mkCRDRef`) that is
  not ready, missing from the cluster, or unreadable, a `!` warning explains
  why cleanup may stall and how to fix it before deploying. Warnings do not
  change the exit code.
- With `--prune`, a `!` warning when the new build no longer declares a
  CustomResourceDefinition (through `scope.mkCRD`, `scope.mkCRDRef`, or
  `kix.mkImport`), while custom resources of that kind remain on the cluster and
  will not be deleted by the prune (such as a Certificate created with
  `kubectl`). Kix excludes objects owned through `ownerReferences` by an object
  that the prune deletes, because Kubernetes deletes them with their owner. Once
  the kind's controller is removed, nothing clears finalizers
  on those objects or cleans up external resources they manage. The warning
  lists up to 20 objects, those with finalizers first. Kix still allows the
  deploy, and the warning does not change the exit code.
- `Not checked by the dry run (N)`, grouped by reason, five names per group.
- A closing note that no preview checks whether Pods start, pull their
  images, and pass their readiness probes.

### Markdown

GitHub-flavoured Markdown for pull request comments: the package plan, then
the Kix library's warnings, the writes the deploy would stop on, the
objects being deleted on the cluster, the prune deletes that will wait, and the
objects the dry run did not check in a `<details>` block.

## Plan file

`--out plan.kixplan` writes the plan as one file that
[`kix deploy --plan`](/docs/reference/cli/deploy/#deploy-a-reviewed-plan)
and Kix Enterprise read. It holds:

- the `Plan` document, with each field change listed;
- the new build's dependency graph, as
  [`kix graph -o json`](/docs/reference/cli/graph/) prints it;
- the old and new manifest of each changed, added, or removed object, each
  as its own file named by its SHA-256. For an object the dry run checked,
  the old manifest is the live object and the new one the dry-run result.
  Secret values are hidden as in [field changes](#field-change-labels), and
  each manifest is whole up to 3 MiB, the apiserver's limit on a request,
  so only a build manifest the cluster would refuse is replaced by a size note.

The file is a seekable zstd file, the container a bundle uses. Any zstd tool
reads it: `zstd -dc plan.kixplan` prints the JSON header object followed by
each manifest JSON document. The same plan gives the same bytes from the same
Kix. The header's JSON Schema is `cli/kix-cli/schema/kixplan.schema.json`.

| Header key | Content |
| --- | --- |
| `format`, `version` | `"kixplan"` and `1`. A Kix refuses any other version. |
| `plan` | The `Plan` document, below. |
| `graph` | `{ nodes, edges }`: each node `{ id, kind, name, namespace, identityHash, isImport }`, each edge `{ from, to }` where `from` depends on `to`. |
| `shown` | By resource identifier, each changed, added, or removed object's `{ package, old, new, rollout }`. `package` is the key `plan.packages` lists the object under (`namespace/instance`, or `_cluster` for a resource outside every package); an object that moves between packages names the one it moves to. `old` and `new` are the SHA-256 of the manifest's file, `null` when that side has none. `rollout` is `restart` when the deploy replaces the object's Pods (a Deployment, StatefulSet, or DaemonSet whose pod template changes), `on_delete` when its new manifest sets `spec.updateStrategy.type: OnDelete`, and `null` otherwise. |
| `files` | Each manifest file as `[sha256, size]`, sorted by SHA-256. Objects with equal manifests share a file. |

A reader recomputes each file's SHA-256 and refuses a file whose bytes do not
match its name. It refuses a plan file over 64 MiB, a header over 8 MiB or
of more than a million JSON values, more than 100,000 files, and a file over
3 MiB, each before reading what the cap guards.

### The `Plan` document

`kix plan --read-only -o json` and `kix diff -o json` print the same
document, so a consumer can read any of them.
Its JSON Schema is `cli/kix-cli/schema/plan.schema.json`.

| Key | Content |
| --- | --- |
| `schema_version` | A date string, `YYYY-MM-DD`, currently `"2026-11-15"`. It changes only when the document changes in a way that is not backward compatible. |
| `made_by` | `dry_run` from `kix plan`; `builds` from `kix plan --offline` or `kix diff --from <build>`; `live_read` from `kix plan --read-only` or `kix diff --from <snapshot>`. |
| `kix` | `{ version, store_path }` of the Kix that made the plan. `store_path` is the store path of the binary, or `null` for a binary built outside the store. |
| `cluster` | The name the build gives the Kix cluster. |
| `kubernetes` | `{ context, server }` for the Kubernetes cluster the plan read: the kubeconfig context and its API server URL, each `null` when not set in the kubeconfig. `null` when the command did not connect to a cluster (`kix plan --offline` and `kix diff`). |
| `build` | The build the plan is for: `{ store_path, identity_hash }`. `store_path` is the build's result directory, the path a deploy records as `kix.run/built-via`; it locates the build. `identity_hash` is the Activation record's `kix.run/identity-hash`, a hash of every rendered manifest and what is upstream of it; two builds with the same identity hash deploy the same objects. Present whether or not anything changes. |
| `head` | The cluster's [deploy lock](/docs/reference/cli/deploy/#the-deploy-lock) state read by the plan: `{ generation, current, lock }`. `generation` is the lock generation a deploy of this plan checks (`0` when the cluster has no `ActivationHead` yet), `current` names the active record on `ActivationHead`, and `lock` is either `null` or the lock holder: `{ holder, hint, purpose, activation, renewed, seconds_since_renewal, probably_dead }`. `seconds_since_renewal` is measured by this machine's clock, and `probably_dead` is `true` when it exceeds the 30-second lease. `head` is `null` when the plan did not read `ActivationHead` (`kix plan --offline`, `kix plan --read-only`, `kix diff`, or when this account cannot read `activationheads.kix.run`). |
| `objects` | Every object the deploy writes or deletes: `{ writes, deletes }`. Each write is `{ kind, group, namespace, name, package, store_hash, change, reason }`, and each delete is `{ kind, group, namespace, name }`. `reason` is omitted when the new build changed the object, and otherwise explains why Kix writes it: `{ kind: "applied_by_record", record }` (applied by an earlier `Failed` or `Partial` deployment record), `{ kind: "left_by_degraded", record }` (missed by a `Degraded` deploy), `{ kind: "applied_hash_missing" }` (no recorded applied hash), `{ kind: "reverts_drift", changed_by }` (drifted fields taken back with force, with `changed_by` listing `{ manager, fields }`), or `{ kind: "held_by_other_cluster", changed_by }` (changed fields owned by another Kix cluster, applied without force). `null` from `kix diff`. |
| `metadata_rewrites` | Number of objects whose metadata the first deploy after upgrading updates to remove legacy annotations and rename the field manager. See [The first deploy after upgrading](/docs/explanation/server-side-apply-and-drift/#the-first-deploy-after-upgrading). Omitted when zero. |
| `deployed` | The build the plan compares against: `{ activation, identity_hash, store_path }` from the cluster's current Activation record (the cached record with `--offline`). `null` on a first deploy. |
| `flags` | The planning flags: `{ prune, reconcile, force_conflicts, accept_migrations, only, operator_removed }`. `prune` says what the deploy does with orphans: `delete` with `--prune`, `skip` with `--skip-orphan-check`, and `warn_only` otherwise. `only` lists the sorted instance names passed to `--only`, and is omitted when `--only` is not set. `operator_removed` is `true` with `--operator-removed`, and is omitted otherwise. `null` from `kix plan --read-only` and `kix diff`. |
| `left_alone` | With `--only`, `{ writes, orphans }`: `writes` counts resources in the build outside this step that differ from the active deployment record (earlier `--only` runs may already have applied some of them), and `orphans` counts removed resources left untouched for a full deploy. `packages`, `objects`, and `prune` include only what this step changes. Omitted without `--only`. |
| `earlier_deploys` | Array of `{ resource, path, deployed, live, record, partly_deployed }`: each field where the live object differs from the active build and matches the build of an unfinished deployment record (`Failed`, or `Partial` from `kix deploy --only` with `partly_deployed: true`). These fields are excluded from `drift`. Omitted when empty. |
| `only_needed` | With `--only`, sorted names of dependency instances that the selected instances require and that this step also deploys in full. Omitted when empty. |
| `packages` | The package-grouped changes, described under [`kix diff`](/docs/reference/cli/diff/#json-and-yaml). |
| `migrations` | Checked section of `{ slot, source, target, reason }`. |
| `conflicts` | Checked section of `{ resource, owners, message }`, each owner `{ manager, fields }`. |
| `admission` | Checked section of `{ resource, reason, webhook, message }`. See [Refusal reasons](#refusal-reasons). |
| `drift` | Checked section of `{ resource, path, live, deployed, managers, reverted }`. A plan lists the drift on the objects the deploy applies, so `reverted` is always true; `kix plan --read-only` also lists drift the deploy leaves alone, with `reverted` false. |
| `being_deleted` | Array of `{ resource, since, finalizers, holds_data }` for each object this deploy applies that is currently being deleted on the cluster. `since` is `metadata.deletionTimestamp`, `finalizers` lists the finalizers still holding the object, and `holds_data` is `true` when the object may hold data (which the recreated object will not keep). Omitted when empty, and omitted by `kix plan --read-only` and `kix diff`. |
| `prune` | Checked section of `{ resource, fate, detail, finalizers, deleting_since, controllers, left_behind }`. See [Prune fates](#prune-fates). `finalizers`, `deleting_since`, and `controllers` appear only when `fate` is `delete` and are omitted when unset or empty. `finalizers` lists any finalizers on the object. `deleting_since` is `metadata.deletionTimestamp` when the object is already being deleted (the deploy waits for that deletion instead of sending a second delete). When `finalizers` is non-empty, `controllers` lists each controller declared for the object's kind (`controller` on `scope.mkCRD` or `scope.mkCRDRef`) as `{ resource, state, detail }`, where `state` is `ready`, `not_ready`, `missing`, or `unread`, and `detail` (when present) explains `not_ready` or `unread`. With `--prune` or `--read-only`, `left_behind` (`{ kind, count, with_finalizers, objects: [{ resource, finalizers }] }`) is set on a CustomResourceDefinition or CRD reference marker (`scope.mkCRDRef` or `kix.mkImport`) when nothing in the new build declares that CRD and custom resources of `kind` will remain on the cluster after the prune. Kix excludes objects owned through `ownerReferences` (directly or indirectly) by an object that the prune deletes, because Kubernetes deletes them with their owner. `count` is the total number of remaining objects, `with_finalizers` is how many of them have finalizers, and `objects` lists up to 20 of them, those with finalizers first (`finalizers` is omitted when empty). |
| `readiness` | Always `{ "status": "not_checked", "reason": "not_previewable" }`. |
| `warnings` | The Kix library's warnings for the build, each with the fields [`kix check`](/docs/reference/cli/check/#library-warnings) gives a warning, without `severity`. Left out when there are none, and for a build read from a bundle. |
| `not_checked` | Array of `{ resource, reason, because, detail }`. `because` names the Namespace, CustomResourceDefinition, or Service that this deploy changes and that the answer depends on, when Kix knows which. Empty unless `made_by` is `dry_run`. |

Each checked section is one of:

```json
{ "status": "checked", "items": [ ... ] }
{ "status": "not_checked", "reason": "read_only" }
```

| `reason` | Meaning |
| --- | --- |
| `builds_only` | Two builds were compared and no cluster was read. `kix plan` against the cluster checks it. |
| `read_only` | A read-only comparison cannot see it, because it shows only on the write path. `kix plan` checks it. |
| `deployed_build_unavailable` | The deployed build's manifests are not on this machine, so a change the commit makes cannot be told apart from drift. |
| `not_previewable` | No preview can tell. |

Resource identifiers have the form `Kind.group/name@namespace`, such as `Deployment.apps/web@shop`. Core `v1` kinds omit `.group` (`Service/web@shop`), and cluster-scoped objects omit `@namespace` (`Namespace/shop`).

## Field change labels

Each field change under `packages.changed[].modified_resources[].changes[]`
is `{ path, change, old, new, labels }`. `change` is `added`, `removed`, or
`changed`; `old` or `new` is absent when that side has no value. When the
deployed build's manifests are on this machine, `labels` says what made the
change:

| Label | Meaning |
| --- | --- |
| `intended` | The deployed build and the new build differ here. |
| `reverts_drift` | The live object differs from the deployed build here, and the deploy applies the object, so it puts the deployed value back. |
| `drift_kept` | From `kix plan --read-only` only. The live object differs from the deployed build here, and the deploy leaves the object alone because its identity hash did not change. `kix deploy --reconcile` applies it. |
| `applied_by_earlier_deploy` | From `kix plan` only. The live value differs from the deployed build and matches an earlier unfinished deploy (a `Failed` deploy or a `Partial` deploy from `--only`). Listed under `earlier_deploys` with its deployment record instead of under `drift`. |

A change can carry both `intended` and a drift label when the commit changes
a field that was also changed on the cluster. Without the deployed build,
`labels` is absent and `drift` is `not_checked` with reason
`deployed_build_unavailable`.

A field another manager changed is usually also owned by that manager, so a
plan reports it as an ownership conflict naming the manager. With
`--force-conflicts` the plan shows it as `reverts_drift` instead.

## Refusal reasons

| `reason` | Meaning |
| --- | --- |
| `webhook_denied` | An admission webhook denied the write. `webhook` names it when the apiserver did. |
| `webhook_unreachable` | The apiserver could not reach the Service behind an admission webhook, and this deploy does not write that Service or any other object in its package. `webhook` names the webhook when the apiserver reported it. See [Objects not checked](#objects-not-checked). |
| `policy_denied` | A ValidatingAdmissionPolicy denied the write. `webhook` names the policy. |
| `invalid` | The object fails validation against the schema or a CRD's rules. |
| `immutable_field` | A changed field cannot be modified; the object must be deleted and created again. |
| `forbidden` | RBAC or an admission plugin forbids the write. |
| `namespace_missing` | The namespace does not exist and the build does not create it. |
| `unknown_kind` | The apiserver does not serve the kind and the build has no CRD for it. |
| `decryption` | A SOPS Secret could not be decrypted. |
| `kix_cluster_conflict` | Another Kix cluster on the same Kubernetes cluster manages the object and sets conflicting values on shared fields. `message` contains the `[K5636]` error naming the other Kix cluster and the conflicting fields. Reported here rather than under `conflicts`. |
| `sops_not_flat` | A top-level value in the Secret's SOPS file is a map, a list, or `null` (`[K6746]`). |
| `other` | Kix refused the object before sending it, the dry-run write failed without a response, or the apiserver returned another error. |

## Prune fates

| `fate` | Meaning |
| --- | --- |
| `delete` | `--prune` deletes it, and the dry-run delete was accepted. |
| `delete_refused` | `--prune` would delete it, but the dry-run delete was refused. The deploy would stop on it. |
| `kept_warn_only` | Kept by a deploy without `--prune`, and recorded on the new Activation for a later `--prune` or `kix gc`. |
| `kept_skipped` | Kept by `--skip-orphan-check`. |
| `kept_never_pruned` | A Namespace or CustomResourceDefinition, which Kix never deletes automatically. |
| `kept_shared` | Another Kix cluster's current build contains it. |
| `kept_changed` | The object was modified between Kix reading it and the dry-run delete on all 5 attempts; the next prune checks it again. |

## Objects not checked

A dry run persists nothing, so an object that needs something the same
deploy creates cannot be checked. These objects are listed under
`not_checked`, not as refusals, and their entries in `packages` come from
comparing builds. Most of a cluster's first deploy is in this list.

An admission webhook that cannot reach its Service is not checked only when
this deploy writes that Service or another object of its package. Otherwise
nothing in the deploy repairs the webhook, so the deploy would fail at the
first object the webhook checks. The plan lists the object as a refusal with
reason `webhook_unreachable`, and the deploy stops before it writes anything. Get the
webhook's backend running again. If someone deleted the Service, or scaled
the workload behind it to 0 replicas, run `kix deploy <cluster> --reconcile`
to restore what the build defines.

| `reason` | Meaning |
| --- | --- |
| `crd_created_by_this_deploy` | Its kind comes from a CRD this deploy creates. |
| `crd_installed_by_kix` | Its kind is a Kix custom resource (such as `Activation` or `PackageInstance`) that the Kubernetes cluster does not serve yet. `kix deploy`, `kix rollback`, `kix gc`, `kix migrate domain`, and the Kix operator install Kix's CRDs automatically before modifying the cluster (`because` names the CRD). Appears on a Kubernetes cluster where Kix has not installed its CRDs yet. |
| `crd_installed_outside_kix` | Its kind comes from a CRD that is not on the cluster yet and is referenced externally (`scope.mkCRDRef` or `kix.mkImport`). Kix does not create the CRD. During deploy, Kix waits for an operator in the build or an external tool to install it, and fails if it never appears. `because` names the CRD when the build references only one external CRD in that API group. Otherwise, `because` is left out. |
| `crd_changed_by_this_deploy` | Its kind's CRD is changed by this deploy, and the cluster refused the object when checking it against the CRD it has now. The deploy applies the CRD first, so the refusal may not happen. |
| `namespace_created_by_this_deploy` | Its namespace is created by this deploy. |
| `webhook_no_dry_run` | An admission webhook that would be called does not support dry run. |
| `webhook_backend_written_by_this_deploy` | An admission webhook that would be called could not reach its Service, because the Service does not exist or has no ready pods. This deploy writes that Service, or another object of the package that owns it, such as the operator's Deployment. `because` names the Service. A webhook that answers and denies the write is still a refusal. |
| `dependency_not_checked` | The engine did not try the object, for example because the dry run was cancelled. `detail` names the object it waited on when there is one. |

## Offline plans

With `--offline`, `kix plan` connects to nothing. It compares the
cached build with the new one and cannot see changes on the cluster. `made_by` is `builds`, and `conflicts`,
`admission`, `drift`, and `prune` are `not_checked` with reason
`builds_only`. The
cache is keyed by cluster name only; see
[`kix deploy`](/docs/reference/cli/deploy/) for what an offline plan
cannot see, and for how `kix deploy --offline` plans again once it connects.

## Exit status

| Code | Meaning |
| --- | --- |
| `0` | The deploy would change nothing and delete nothing |
| `2` | The deploy would change something, or the prune would delete something |
| `3` | The deploy would stop: a refused write, a refused prune delete, or a stateful migration without `--accept-migrations` |
| `1` | Evaluation, build, or cluster error |

The status is the same for every output format. A command line that cannot
be parsed also exits `2`; see [Exit codes](/docs/reference/cli/exit-codes/).

In CI, treat `0` and `2` as success and fail the job on anything else:

```bash
status=0
kix plan prod --out plan.kixplan || status=$?
case "$status" in
  0|2) ;;
  3) echo "the deploy would stop; see the plan above" >&2; exit 1 ;;
  *) exit "$status" ;;
esac
```

A build with no resources prints `Nothing to deploy.` and exits `0` when
`--out` is not set. With `--out`, it fails with
`the build has no resources, so there is no plan to save`, writes no file, and
exits `1`.

To deploy exactly what a reviewer approved, pass the plan file to
[`kix deploy --plan`](/docs/reference/cli/deploy/#deploy-a-reviewed-plan),
which refuses when the plan made at deploy time differs.

A dry run relies on every server it reaches to honour `dryRun=All`. An
aggregated API server that ignores the parameter, or an admission webhook
that declares `sideEffects: None` but has side effects, can still change
something.

## Read-only plans

`kix plan --read-only` reads the live cluster and sends no writes, so it
needs only `get` and `list`. It compares the build with what the cluster
runs and prints the same package-grouped report as
[`kix diff`](/docs/reference/cli/diff/#what-is-compared). A read cannot see
what shows only on the write path, so the report ends with the checks it
could not make: admission webhooks and policies, field ownership conflicts,
and what the deploy itself refuses.

It cannot be combined with `--offline`, `--reconcile`, `--prune`,
`--skip-orphan-check`, `--force-conflicts`, `--accept-migrations`, or
`--deployed-bundle`.

For each managed resource, Kix reads only the fields it applied. Kubernetes
records which tool set each field through server-side apply, and Kix keeps its
own fields and drops the rest: server defaults, status, and fields set by
controllers or `kubectl`. A cluster that matches its build reports no
differences.

The live side holds only the named cluster's resources: those referenced by its
deployment records via revisions (or via `kix.run/activations` on clusters not
yet upgraded to revisions). When
the Kubernetes cluster also runs other Kix clusters, their resources are not
reported as removals, and stderr says how many were skipped and which
clusters they belong to. A
resource the build drops that another Kix cluster's current build still
contains is left out too, since `kix deploy --prune` keeps it.

A read-only plan also prints an error for each build resource whose kind the
cluster serves as namespaced but whose manifest has no `metadata.namespace`.
`kix deploy` refuses to apply a build that contains one.

When the deployed build's manifests are on this machine, each field change
carries a [label](#field-change-labels), and a Drift section lists each field
where the live object differs from the deployed build, with its live and
deployed values, the field managers that own it live, and whether the deploy
reverts it. Without the deployed build nothing is labelled, and the drift
section is not checked.

In the `Plan` document, `made_by` is `live_read`, `flags` is `null`,
`conflicts` and `admission` are `not_checked` with reason `read_only`, and
`not_checked` is empty. `prune` lists each orphan as `kept_warn_only`, or
`kept_never_pruned` for a Namespace or CustomResourceDefinition. Because
previewing deletions requires dry-run `delete` requests, `kix plan --read-only`
does not accept `--prune`. Checking what `kix deploy --prune` would leave on
the cluster needs only `get` and `list`, so a removed
CustomResourceDefinition or CRD reference still sets `left_behind` on its
`prune` entry (see [The `Plan` document](#the-plan-document)), and text and
Markdown output warn when the plan has changes. CI jobs with read-only
cluster access can inspect `left_behind` in `kix plan --read-only -o json`.

The exit status is `0` when nothing differs, `2` when something does or a
stateful migration was detected, and `1` on an evaluation, build, or cluster
error.

## Relation to `kix diff` and `kix deploy`

| | `kix plan` | `kix plan --read-only` | `kix diff` |
| --- | --- | --- | --- |
| Reads | The cluster, and sends dry-run writes | The cluster, with `get` and `list` | Two builds or a saved directory; never the cluster |
| Permissions | The deployer's | `get` and `list` | None |
| Field changes | Live object against the dry-run result | Build against the Kix-owned view of the live object | Build against build |
| Ownership conflicts, webhooks, admission policies, validation, RBAC | Checked | `not_checked` (`read_only`) | `not_checked` |
| Prune fates | Checked | Orphans listed as `kept_warn_only` or `kept_never_pruned`, with `left_behind` when custom resources remain | `not_checked` |
| Drift | Fields the deploy touches | Every drifted field, with whether the deploy reverts it | Not checked |
| `made_by` | `dry_run` (`builds` with `--offline`) | `live_read` | `builds`, or `live_read` with a snapshot |

Use `kix plan` to preview a deploy you are about to run. Use
`kix plan --read-only` when the job has read-only credentials. Use
`kix diff` when the job has no cluster at all, such as a pull request check
against a snapshot.

`kix deploy` makes the same plan before it asks for confirmation. Under
`--on-error stop`, the default, it stops before applying anything when the
plan shows a refused write. See [`kix deploy`](/docs/reference/cli/deploy/).

## Examples

<Command commands={[
  "kix plan demo",
  "kix plan demo --prune --reconcile",
  "kix plan demo --out plan.kixplan",
  "kix plan demo -o markdown > plan.md",
  "kix plan demo --read-only",
  "kix plan demo --read-only -o json --detail fields",
]} />

:::tip[Use it in a task]
See [Preview changes with `kix plan`](/docs/how-to/operate-a-cluster/preview-changes-with-kix-plan/)
for when to use each preview.
:::