# `status`

`kix status` checks what Kix deployed. For every object of a Kix cluster's
current deploy, it answers three questions: is the object on the cluster, does
it still hold what Kix applied, and is it ready. It reads the Kubernetes
cluster through your kubeconfig and works outside a project directory. Inside a
project (or with `--flake`), if `CLUSTER` does not match any deploy record on
the Kubernetes cluster, Kix evaluates `flake.nix` to look up the `name` set in
that cluster's definition.

`kix health`, `kix drift`, and `kix status --operator` were removed in 0.10.
Use `kix status <cluster> --check presence`, `kix status [cluster] --check drift`,
and `kix status <cluster>` instead, in that order. The old forms stop with an error that
prints `[K6116]` and names the replacement.

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

## Synopsis

```text
kix status [CLUSTER] [--check presence|drift|readiness]... [--package <NAME>]
           [-o text|json|yaml] [-v] [-q] [--context <CONTEXT>]
```

| Argument or flag | Meaning |
| --- | --- |
| `[CLUSTER]` | Kix cluster to check: either its key in `flake.nix` or the name on its deploy records (`kix.run/cluster`). When omitted, Kix checks every Kix cluster with a current deploy in the selected Kubernetes context. |
| `--check <CHECK>` | Run only this check: `presence`, `drift`, or `readiness`. Repeat it to run more than one. Without it, all three run. Every check reports a missing object. |
| `--package <NAME>` | Show only this package, by instance name (`web`) or `namespace/instance` (`shop/web`). An error when no checked cluster has the package. The error lists the packages, or the five closest names when there are more than ten. |
| `-o`, `--output` | `text` (default), `json`, or `yaml`. Other formats are refused. |
| `-v` | List every object, with or without a problem, and print the Kubernetes cluster ID. |
| `-q`, `--quiet` | Print only the objects with a problem. |
| `--context <CONTEXT>` | Kubeconfig context to read. Defaults to the current context. |

`--no-cache` has no effect. `--flake` and `--override-input` apply only when
`CLUSTER` matches no deploy record on the Kubernetes cluster and Kix evaluates
`flake.nix` to look up the cluster's deployed `name`. See
[Global flags](/docs/reference/cli/global-flags/).

## The checks

Each check runs on every object that the cluster's current deploy made. The
current deploy is the cluster's `Active` or `Degraded`
[Activation record](/docs/reference/annotations-crds-and-receipts/#activation).

| Check | Question | An object fails when |
| --- | --- | --- |
| `presence` | Is the object on the cluster? | It is gone, for example after a `kubectl delete`. |
| `drift` | Does the object still hold what Kix applied? | The fields Kix owns no longer hash to the applied hash Kix recorded for the object in its [revision's](/docs/reference/annotations-crds-and-receipts/#packageinstancerevision) `status.applied`. |
| `readiness` | Is the object ready? | It is not ready by the rules [`kix deploy`](/docs/reference/cli/deploy/) waits on, such as a Deployment with fewer ready replicas than it wants. |

`kix status` checks only the objects listed in the current deploy record, with
one exception: it also reports Kix-managed objects of this Kix cluster that are
not in the current deploy and are still being deleted (see
[Objects being deleted](#objects-being-deleted)). It never reports other extra
objects on the cluster, whether orphaned from an earlier deploy or created
outside Kix. See [Objects Kix did not apply](/docs/reference/cli/diff/#objects-kix-did-not-apply).

The `readiness` check reflects what Kubernetes and each object's controller
report on the cluster. It does not test external calls from inside your pods;
for example, a pod that starts and passes its probes counts as ready even if a
cloud API rejects its requests. See
[What readiness does not show](/docs/how-to/operate-a-cluster/check-resource-status/#what-readiness-does-not-show).

A missing object is a problem under every check, because no check can run on
an object that is gone. `kix status --check drift` and
`kix status --check readiness` therefore also report missing objects.

## Objects being deleted

When Kubernetes deletes an object, it sets `metadata.deletionTimestamp` and
keeps the object on the cluster until every finalizer on it is removed,
usually by the controller that added it. If an object in the current deploy is
being deleted, every check (`presence`, `drift`, and `readiness`) reports it
as `being deleted` (`deleting` in JSON and YAML) instead of `changed` or
`not ready`. Its line shows when deletion started and any finalizers still on
it. Run `kix deploy <cluster> --reconcile` (or deploy a change to the object)
to wait for deletion to finish and recreate it.

If a Kix-managed object of this cluster is not in the current deploy and is
still being deleted (for example, during `kix deploy --prune` or `kix gc`),
`kix status` lists it after the packages under
`Not in the current deploy, still being deleted`. Each one counts as a problem
and is included on the summary line. `--package` narrows this list to objects
from that package. Kept orphans that are not being deleted are not shown.

The drift check hashes only the fields Kix owns through server-side apply. A
field Kix never set, such as one a controller adds, does not count. A change
made through the `/scale` subresource, such as `kubectl scale` or an
autoscaler, counts when Kix set the replica count. For a changed object, Kix
reads `metadata.managedFields` to name each changed field and the field
manager that now owns it. See
[Server-side apply and drift](/docs/explanation/server-side-apply-and-drift/).

A Job that finished counts as present and ready. Jobs that Kix builds do not
delete themselves, so a Job that is gone is missing.

## Failed deploys

When a deploy fails, the previous deploy record stays current. If a deploy has
failed since the current deploy finished, `kix status` reports the failed
deploy and exits `2`. The header shows the failed deploy first (with when and
why it failed), followed by the current deploy.

Any object in the failed build that is not in the current deploy (matched by
kind, namespace, and name) is checked the same way and listed under
`Only in the failed deploy <record>`. For example, this section includes a new
`LoadBalancer` Service from the failed deploy that never received an address.
Objects present in both builds are checked once under the current deploy
against the live cluster state.

## Deploy lock

When another run holds the cluster's
[deploy lock](/docs/reference/cli/deploy/#the-deploy-lock), `kix status`
prints a line after the cluster's notes showing who holds the lock, what it is
doing, and how long ago it renewed its lease (measured by this machine's
clock):

```text
kix deploy by ana@laptop, process 4242 holds the deploy lock (deploy of prod-3f2a9c1b04de), renewed 4s ago.
```

If more than 30 seconds have passed since the last renewal, the line notes
that the lease has expired, the holder has likely stopped, and the next
command that changes the cluster will take over the lock. Because `kix status`
compares the timestamp against this machine's clock, clock skew between
machines can make a live lock look expired; only a command that changes the
cluster watches the lock to confirm. `kix status` never waits for or takes the
lock, and `-q` omits this line.

## How workload readiness is reported

When a Deployment, StatefulSet, or DaemonSet is not ready, `kix status`
inspects its pods and reports the same details that `kix deploy` shows while
waiting: how many pods on the current revision are ready, why the first unready
pod is waiting (such as a scheduling error or a failing readiness probe), and
whether an unready pod on an older revision is blocking a StatefulSet update.
This adds one or two API list requests per unready workload, and none for ready
workloads. If Kix cannot list the pods (or the controller has not acted on the
current revision yet), the output falls back to the counts on the workload's
status.

## Text output

The text output has four parts:

1. A line for each package, with its object count and either `ok` or the
   counts of its problems. Objects that no package owns, such as Namespaces
   and CustomResourceDefinitions, are listed under `(cluster-level)`.
2. The objects with a problem, grouped by package.
3. Any objects not in the current deploy that are still being deleted.
4. A summary line with the counts.
5. When an object is missing or changed, a `Next:` line that names
   `kix deploy <cluster>` to restore what is missing or changed, and
   `kix plan <cluster>` to preview those changes first (see
   [How a deploy decides what to write](/docs/reference/cli/deploy/#how-a-deploy-decides-what-to-write)).
   When another field manager owns fields on a changed object and Kix does not
   co-own them (for example, after `kubectl edit` or `kubectl scale`), the line
   names that manager and notes that the deploy takes its fields back. A
   manager that co-owns all its fields with Kix changed none of them. When the
   manager is another Kix cluster (or `kix` from an earlier version of Kix),
   the line explains that `kix deploy` will not overwrite those fields and tells
   you to update the cluster definitions to match.

```text
Cluster shop on Kubernetes v1.33.1 (context prod, https://prod.example:6443)
Last deploy: shop-7f3a2b1c0d9e  Active  2d0h ago

  db/postgres              2 resources  1 changed
  ingress/ingress-nginx    1 resource   ok
  vault/vaultwarden        4 resources  1 not ready, 1 missing, 2 not checked
  (cluster-level)          1 resource   ok

db/postgres
  ConfigMap db/pg-config        changed since deploy (data.max_connections by kubectl-edit)
vault/vaultwarden
  Deployment.apps vault/vaultwarden  not ready (0/1 ready, 0/1 updated)
  Secret vault/vaultwarden-db        missing, needed by Deployment.apps vault/vaultwarden

8 resources: 3 ok, 1 changed, 1 not ready, 1 missing, 2 not checked.
Next: run `kix deploy shop` to restore what is missing or changed, or `kix plan shop` to preview the changes first. The deploy takes back the fields that kubectl-edit owns.

This account may not list secrets, so Kix did not check objects of those kinds.
```

With `-v`, the second part lists every object, and the header adds the
Kubernetes cluster ID (the UID of the `kube-system` Namespace, the value
[`cluster.kubernetes.uid`](/docs/reference/cluster-configuration/) takes):

```text
Cluster shop on Kubernetes v1.33.1 (context prod, https://prod.example:6443)
Kubernetes cluster ID: 4d7b1c2e
Last deploy: shop-7f3a2b1c0d9e  Active  2d0h ago
...
vault/vaultwarden
  Deployment.apps vault/vaultwarden  not ready (0/1 ready, 0/1 updated)
  ConfigMap vault/vaultwarden-env    not checked for changes: Kix has no recorded applied hash; `kix deploy` reapplies this object and records it
  Secret vault/vaultwarden-db        missing, needed by Deployment.apps vault/vaultwarden
  Secret vault/vaultwarden-admin     not checked: this account may not list its kind
(cluster-level)
  Namespace vault                   ok
```

With `-q`, only the second part is printed. When more than one Kix cluster is
checked, each cluster gets its own block, and a closing line gives the counts
over all of them.

## Objects that are not checked

Some objects cannot be checked. Kix shows them as "not checked" and they do
not fail the command:

- **A kind the account may not list.** When listing a resource type returns
  `403`, Kix cannot tell whether its objects are on the cluster, so it does
  not report them as missing. A closing line names the resource types.
- **No applied hash.** Kix has no recorded applied hash for the object (for
  example, if a deploy stopped after applying the object but before recording
  its hash). The next `kix deploy` reapplies the object and records its hash.
  On clusters not yet upgraded to revisions, Kix reads the hash from the
  object's `kix.run/applied-hash` annotation.
- **No field ownership entry for Kix.** Kubernetes records no fields owned by
  the Kix cluster's field manager (`kix/<cluster>`), so the drift check has
  nothing to compare.

The summary line and the package lines count these objects as `not checked`.
`ok` counts only the objects that every selected check passed.

## How missing objects are named

A missing object is gone from the cluster, so Kix cannot read its kind or name
there. Kix names it from the first of these that has it:

1. The deploy record. Each deploy links to
   [revisions](/docs/reference/annotations-crds-and-receipts/#packageinstancerevision)
   listing the kind, namespace, and name of every object (older records may
   list them in
   [`status.packageIndex`](/docs/reference/annotations-crds-and-receipts/#the-package-index)).
2. Kix's local store, when it holds the deployed build.
3. Neither. The object is shown as `Unknown/(hash: xxxxxxxxxxxx...)`.

The line for a missing object names the objects that depend on it, such as
`missing, needed by Deployment.apps vault/vaultwarden`.

A record with neither revisions nor a package index lists no objects. Kix then
finds the deploy's objects through the `kix.run/depends-on` annotations of the
deploy's live objects. When such a record's own object is also gone, Kix cannot
tell which objects the deploy made, says so, and exits `1`.

## JSON and YAML output

`-o json` and `-o yaml` print one document. Its JSON Schema is
`cli/kix-cli/schema/status.schema.json`. Programs that read it must skip
fields and values they do not know.

| Field | Meaning |
| --- | --- |
| `schema_version` | Version of the document's shape. |
| `kubernetes` | The Kubernetes cluster read: `context`, `server` (the API server URL in the kubeconfig, or `null` when not set), `uid` (`null` when the account may not read the `kube-system` Namespace), and `version`. |
| `checks` | The checks that ran: `presence`, `drift`, `readiness`. |
| `unreadable` | Resource types the account may not list, such as `secrets`. |
| `clusters[]` | One entry for each Kix cluster checked. |
| `clusters[].cluster` | The Kix cluster name. |
| `clusters[].deploy` | The current deploy record: `name`, `phase` (`Active` or `Degraded`), `identity_hash`, `deployed_at`, and `deployed_with` (the version of Kix that deployed, when the record says). |
| `clusters[].objects_from` | Where Kix found the deploy's objects: `index` (the record's revisions, or `status.packageIndex` on older records), `depends_on` (the live objects' `kix.run/depends-on` annotations), or `unknown` (nowhere; no object was checked). |
| `clusters[].notes` | Warnings about the cluster, such as a changed platform interface, a `Partial` deployment record from [`kix deploy --only`](/docs/reference/cli/deploy/#deploy-one-instance-at-a-time), or an earlier `Failed` deployment record (excluding the newest failed deploy already reported in [Failed deploys](#failed-deploys)). |
| `clusters[].packages[]` | One entry for each package, with `name` (`namespace/instance`, or `null` for the cluster-level objects), `summary`, and `resources`. |
| `clusters[].failed_deploy` | The newest deploy that failed since `deploy`, or `null`: `name`, `identity_hash`, `failed_at`, `reason`, `packages` (objects present only in the failed build, in the same shape as `clusters[].packages`), and `summary` (counts for those objects, which are excluded from the cluster's `summary`). |
| `clusters[].lock` | Current [deploy lock](/docs/reference/cli/deploy/#the-deploy-lock) holder, or `null` when the cluster is unlocked or this account cannot read `activationheads.kix.run`: `holder` (run ID), `hint` (human-readable caller), `purpose` (`deploy`, `rollback`, `gc`, `migrate`, `repair`, or `teardown`), `activation` (record being deployed, or `null`), `renewed` (RFC 3339 timestamp from the holder's clock), `seconds_since_renewal` (measured by this machine's clock, or `null`), and `probably_dead` (`true` when `seconds_since_renewal` exceeds the 30-second lease). |
| `clusters[].leaving[]` | Kix-managed objects of this Kix cluster that are not in the current deploy and are still being deleted. Each entry has `kind`, `group` (omitted for core `v1` kinds), `namespace` (`null` when cluster-scoped), `name`, `package` (`namespace/instance`, or `null`), `deleting_since` (`metadata.deletionTimestamp`), and `finalizers`. |
| `summary` | Counts over every cluster: `resources`, `ok`, `missing`, `changed`, `not_ready`, `deleting` (objects in the current deploy being deleted), `leaving` (objects in `leaving[]`, not counted in `resources`, and `0` on a package `summary`), `not_checked`, and `failed_deploys` (Kix clusters where a deploy failed since the current deploy; `0` on a package `summary`). Each cluster and package has the same object. `ok` counts only the objects that every selected check passed. An object with two problems counts under both. |

Each entry of `resources[]`:

| Field | Meaning |
| --- | --- |
| `kind`, `namespace`, `name` | The object. `namespace` is `null` for a cluster-scoped object. `kind` is `Unknown` when Kix cannot name a missing object. |
| `group` | The kind's API group, such as `apps`. Omitted for core `v1` kinds. |
| `identity_hash` | The object's `kix.run/identity-hash`. |
| `named` | `false` when Kix could not name a missing object. |
| `present` | `yes`, `no`, `external` (an import marker for an object Kix does not manage), `unknown` (the account may not list the kind), or `ambiguous` (no live object matches its identity hash, multiple API groups serve its kind, and an older deploy record lacks its API group; run `kix deploy <cluster> --reconcile` to record it). |
| `drift` | `null` when the drift check did not run or the object is gone. Otherwise `verdict` (`in_sync`, `changed`, `unstamped`, or `no_fieldset`), `foreign_owners` (other field managers, each with `manager`, `operation`, `subresource`, `time`, `paths`, and `unshared_paths`; `unshared_paths` lists the paths Kix does not co-own, which can conflict on deploy), and `unrecorded_scale` (a replica count changed through `/scale` that Kubernetes recorded no owner for). |
| `ready` | `true` or `false` (always `false` while an object is being deleted). `null` when the readiness check did not run, when the object is gone, or when the object is not being deleted and has no readiness check (such as a ConfigMap, or a Service of a type other than `LoadBalancer`). |
| `not_ready_reason` | Why the object is not ready, such as `0/1 ready, 0/1 updated`. |
| `needed_by` | For a missing object, the objects that depend on it, as `Kind.group namespace/name` (or `Kind namespace/name` for core `v1` kinds). |
| `deleting_since`, `finalizers` | When the object is being deleted, `deleting_since` is `metadata.deletionTimestamp` and `finalizers` lists any finalizers still on it. `deleting_since` is omitted when the object is not being deleted; `finalizers` is omitted when empty. |
| `problems` | Any of `missing`, `changed`, `not_ready`, and `deleting` (`deleting` replaces `changed` and `not_ready`). Empty when the object is fine. |
| `not_checked` | Whether a selected check could not run on the object. |

## Examples

<Command commands={[
  "kix status shop",
  "kix status shop --check drift --check presence",
  "kix status shop --package web -o json",
  "kix status --context prod -q",
]} />

## Exit status

| Code | Meaning |
| --- | --- |
| `0` | Every selected check passed. Objects that were not checked do not count. |
| `1` | Kix could not answer: no connection to the cluster, no current deploy for the named cluster, no Kix cluster deployed on the Kubernetes cluster, a `--package` that matches no package, or a record that lists no objects and whose own object is gone. |
| `2` | An object is missing, changed, not ready, or being deleted (including objects outside the current deploy), or a deploy has failed since the current deploy. |

A command line Kix cannot use exits `1`, including `kix health`, `kix drift`,
and `kix status --operator`, which 0.10 removed. So `2` always means that
`kix status` ran and found a problem.

:::tip[Use it in a task]
See [Check a cluster's status](/docs/how-to/operate-a-cluster/check-resource-status/)
for reading the output, then [Reconcile drift](/docs/how-to/operate-a-cluster/reconcile-drift/)
to put back what changed.
:::