Skip to content
Install the CLI

Reference CLI

diff

These docs describe Kix's main branch, which can include changes not yet released. Read the docs for the latest release.

kix diff evaluates and builds a cluster, or reads the build from a bundle with --bundle, then compares the result with a baseline: a directory passed with --from, or a bundle passed with --from-bundle. With --bundle and no baseline, it compares the bundle with nothing, so every package is added. It never contacts a cluster, so it needs no cluster access at all. kix diff <CLUSTER> with none of these flags is refused.

To compare a build with the live cluster, use kix plan --read-only, which reads the cluster with get and list. To preview a deploy you are about to run, use kix plan, which sends each write as a server-side dry run.

This page is hand-maintained. Check cli/kix-cli/src/cli.rs and cli/kix-cli/src/commands/diff.rs when in doubt.

kix diff <CLUSTER> --from <PATH> [--bundle <FILE>]
[-o text|json|yaml|markdown]
[--detail plain|fields|manifests] [--out <FILE>]
[--flake <FLAKE>]
kix diff <CLUSTER> --bundle <FILE> [--from-bundle <FILE>] [...]
Argument or flagMeaning
<CLUSTER>Cluster name to evaluate and build from the flake. This is the new side of the comparison.
--bundle <FILE>Read the new side from a bundle written by kix bundle instead of building from the flake.
--from <PATH>Use a local build or manifest directory as the baseline. See Baseline.
--from-bundle <FILE>Use a bundle as the baseline. Needs --bundle. Not with --from.
-o, --outputtext (default), json, yaml (the JSON document as YAML), or markdown for pull request comments.
--detail <LEVEL>How much json and yaml say about each change: plain (default) names each changed resource and counts its changed fields, fields also lists each field change, and manifests also includes the old and new manifest of each changed, added, or removed resource. Text and Markdown are the same at every level.
--out <FILE>Also write the comparison to FILE as a plan file, whatever --detail and --output say. It is for reading, by people and Kix Enterprise; kix deploy --plan takes only a kix plan plan file.
--flake <FLAKE>Flake to evaluate. Defaults to the current directory.
BaselineHow to select it
Bundled build--from-bundle <FILE>, with --bundle for the new side
Nothing (every package is added)--bundle <FILE> alone
Saved manifests--from <DIR> where <DIR> holds YAML written by kix snapshot or kix export --with-kix-metadata
Previous build--from <PATH> where <PATH> is the activation index path (kix.run/built-via) of a build in Kix’s local store, or a directory containing kix-packages.json whose referenced store paths exist in Kix’s local store

Each bundle is checked against its content as it is read, and must be a build of <CLUSTER>, as for kix plan --bundle. A bundled baseline is a build, so the report is the one --from <build> gives.

A manifest directory must carry the Kix annotations that name each resource’s package and identity hash. The default kix export output strips them, so use --with-kix-metadata when the baseline comes from an export.

Every baseline goes through the same comparison that kix plan --read-only runs against the live cluster. The live cluster and a snapshot of it produce the same report.

The report is organised by package. Each package lands in one group:

GroupMeaning
addedThe package is in the build but not in the baseline
removedThe package is in the baseline but not in the build
changedThe package exists on both sides and at least one resource differs
unchangedEvery resource in the package matches

Within a changed package, each resource is reported as one of:

Resource lineMeaning
+ added or - removedThe resource exists on one side only
~ modifiedThe content differs. Text output shows each differing path with a unified diff of the values.
~ tracking annotation onlyOnly the identity hash changed, because a dependency of this resource changed. The content is the same, so pods do not restart. Text and Markdown output mark these “tracking annotation only”; JSON calls them dep_affected_resources.

Two more sections follow the packages:

  • Cluster-level resources groups resources that belong to no package, such as namespaces and custom resource definitions. Text output labels the group cluster-level resources; JSON uses the key _cluster.
  • Activation shows the old and new activation record names when they differ. A build whose content matches the baseline keeps the same record name, so this line appears only alongside other changes.

When a stateful resource appears to have moved between packages or names, the report adds a “Stateful workload replacements” section. It is informational; Kix does not migrate data.

Kix sets the label app.kubernetes.io/managed-by=kix on every object it applies. Every command that reads the live cluster (kix plan, kix plan --read-only, kix snapshot, kix status, kix gc, and kix deploy), along with the Kix operator, lists only objects carrying that label.

CommandObjects Kix applied that left the buildObjects Kix never applied (no Kix label)
kix diffShown as removed (-) when present in the baseline (an earlier build, a bundle, a kix snapshot directory, or a kix export --with-kix-metadata directory) and absent from the new build.Never contacts the cluster. A kix snapshot baseline uses the same label selector, so unlabelled objects never appear.
kix planLists each orphan and its prune fate, read from the live objects listed in the Active record’s revisions, its kept-orphans revision (from deploys run without --prune), and any Failed or Partial record’s revisions.Never listed or compared, unless an object in the build has the same kind, namespace, and name (see below).
kix plan --read-onlyShown as removed (-) in the package report when the live object carries the Kix label and one of this cluster’s deployment records references it (via revisions, or via kix.run/activations on clusters not yet upgraded to revisions). Prune fates are not checked.Never listed or compared.
kix status --check presence / --check driftNever reported. Checks only the objects listed in the current deploy record, reporting missing or changed objects.Never listed, compared, or counted.
kix gcDeletes orphans found by comparing the deployed builds against a fresh build.Never listed or deleted.
kix gc --full-scanScans every labelled object of the named cluster and deletes those whose kix.run/identity-hash is absent from the fresh build.Never listed or deleted.

Even when an object carries app.kubernetes.io/managed-by=kix, Kix separates what it wrote from objects created by other tools or controllers:

  • Managed objects carry kix.run/identity-hash and a managedFields entry for a Kix field manager (kix/<cluster>, or kix from an earlier version of Kix).
  • Unstamped objects carry the label and a managedFields entry for a Kix field manager, but no kix.run/identity-hash (excluding controller-owned child objects and Service Endpoints, which Kix ignores). Kix wrote them, but cannot match them to a build.
  • Copies carry the label without a managedFields entry for a Kix field manager (excluding, for objects without kix.run/identity-hash, the ignored child objects and Endpoints above). Another controller or tool copied Kix’s labels, and sometimes its annotations, onto a new object, such as a database operator’s volume claim or an Event posted for a custom resource.

If Kubernetes serves the same object under multiple API groups (such as Event under v1 and events.k8s.io/v1), Kix includes it once, preferring the API group Kix applied it with.

kix gc --full-scan lists unstamped objects, copies, and unattributed objects (objects with no matching Activation record on the cluster) and keeps them unless you include them with --include (for example, --include unstamped,copies,unattributed).

The one exception for unlabelled objects is a name collision: if an unlabelled live object has the same kind, namespace, and name as a resource in the build, kix plan and kix deploy target that object. kix plan reports field ownership conflicts and names each field’s current manager, and kix deploy stops on those conflicts unless --force-conflicts is passed.

Kix has no command to report unlabelled objects in namespaces it manages. Objects without the Kix label, such as a Flux HelmRelease applied with kubectl apply, never appear in kix diff, kix plan, kix status, or kix gc output. To find objects lacking Kix’s label, query kubectl with app.kubernetes.io/managed-by!=kix (in Kubernetes, key!=value also matches objects without the key). Query specific kinds rather than all built-in kinds, which also return controller-created Pods, ReplicaSets, and EndpointSlices:

❱ kubectl get helmreleases.helm.toolkit.fluxcd.io -A -l 'app.kubernetes.io/managed-by!=kix'

Against a previous build, every field change is labelled intended, and drift is not checked. The labels, and the Drift section that kix plan --read-only adds against the live cluster, are described under Field change labels.

A summary line, one block per namespace with each package’s status and resource lines, the cluster-level group, the activation line, then either the migration section or No differences found. A field change that puts back a drifted field is tagged (reverts drift), and one the deploy leaves alone is tagged (drift; deploy leaves this object alone). The Drift section follows when any field drifted. When there are changes, the output ends with a note that the comparison cannot see admission webhooks, field ownership conflicts, or what the deploy refuses. Colour follows --no-color and the NO_COLOR environment variable.

The Plan document a plan file holds, with JSON Schema cli/kix-cli/schema/plan.schema.json. That page describes the top-level keys, the checked-section shape, and the not_checked reasons. For kix diff:

KeyValue from kix diff
made_bylive_read with a snapshot or export directory; builds with --from <build> or --from-bundle
buildThe new build, as for kix plan
deployedThe baseline’s Activation record: the --from build’s record, or the record in a --from snapshot. null when there is none
flagsnull: a diff plans no deploy
migrationsChecked: the stateful migrations the comparison found
driftnot_checked: deployed_build_unavailable for a snapshot, builds_only with --from <build>
conflicts, admission, prunenot_checked, reason read_only for a snapshot, builds_only with --from <build>
readinessnot_checked, reason not_previewable
not_checkedAlways empty

packages holds the package-grouped changes:

KeyContent
packages.summaryCounts of added, removed, changed, and unchanged packages
packages.added, packages.removedArrays of { key, version, resources, kept_resources, manifests }. resources counts every resource in the package; kept_resources lists the resources that stay on the cluster: Namespaces, CustomResourceDefinitions, and objects another Kix cluster’s current build contains (always empty on added). manifests is present at --detail manifests: the new manifest of each resource of an added package, or the old manifest of each resource a removed package deletes
packages.changedArray of package changes: key, old_version, new_version, added_resources, removed_resources, kept_resources, modified_resources, dep_affected_resources, and at --detail manifests manifests. A resource that left the build and stays on the cluster is listed in kept_resources, not removed_resources
packages.changed[].manifestsObject keyed by resource, each { old, new }, for every modified, added, and removed resource. A side is absent when the resource does not exist there
packages.changed[].modified_resourcesArray of { resource, diff_count, changes }. changes is present at --detail fields and --detail manifests. Each entry of changes is { path, change, old, new, labels }; change is added, removed, or changed, old or new is absent when that side has no value, and labels is absent when the deployed build is not on this machine
packages.cluster_levelThe same shape as one changed package, with key _cluster, or null
packages.activation{ old, new } record names, or null when unchanged
packages.unchangedNumber of unchanged packages

Stateful migrations are under the top-level migrations section, each { slot, source, target, reason }.

A Secret value reads (secret, not shown), or (secret, changed, not shown) on the new side when the value changes. Secret hashes and checksum/* annotations read (hash, not shown) or (hash, changed, not shown). A field value larger than 16 KiB, or a manifest larger than 3 MiB (the apiserver’s limit on a request), reads (N bytes, not shown).

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). Package keys have the form namespace/name.

GitHub-flavoured Markdown: a plan summary, a <details> block per changed package, the cluster-level and activation sections, and the migration section when present.

CodeMeaning
0No differences
2At least one difference, or a stateful migration was detected
1Evaluation or build error

The status is the same for every output format, so a CI job can write Markdown to a file and still branch on the result.