How-to guide / Operate a cluster
Deploy with dry-run, timeouts, pruning, and log/TUI output modes
These docs describe Kix's main branch, which can include changes not yet released. Read the docs for the latest release.
Use deploy controls when the ordinary kix deploy <cluster> workflow needs a
safer preview, different wait limits, orphan cleanup, or structured event
logs. This guide assumes Kix can reach the target Kubernetes context.
Preview the apply
Section titled “Preview the apply”Add --dry-run to send the apply and delete requests to the Kubernetes API
server without persisting them:
❱ kix deploy how-to-application --dry-run --timeout 5m --prune --log-format line Show outputHide output · 25 lines
Building cluster 'how-to-application'...
Cluster how-to-application: 15 manifests
Connecting to context kind-kix-docs (https://127.0.0.1:40563)...
Current deployment: how-to-application-6n94gibgl7zv (build 6n94gibg...)
how-to-app
~ preview 1.0.0 (1 changed, 3 tracking annotation only)
~ ConfigMap/preview@how-to-app
~ $.data.index.html:
--- old
+++ new
@@ -1 +1 @@
-Hello from preview
+Preview deploy controls
~ Deployment.apps/preview@how-to-app (tracking annotation only; no spec change or restart)
~ Service/preview@how-to-app (tracking annotation only; no spec change or restart)
~ PackageInstance.kix.run/preview@how-to-app (tracking annotation only; no spec change or restart)
Plan: 1 updated, 3 unchanged
Resources: 1 changed in content, 3 tracking annotation only (no spec change or restart)
Not checked by any preview: whether Pods start, pull their images, and pass their readiness probes.
Objects: 5 to write, 0 to delete (sha256:97523984ad8482d5c285aa4ffd2d38bc4d7cf8b19c793f737a29b452cb95b505)
(exit code: 2) kix deploy --dry-run runs kix plan with the
same planning flags, so admission checks, permissions, and field conflicts
are evaluated, and every refused write is listed. It does not ask for
confirmation and does not create an activation record. It exits 2 when the
deploy would change something and 3 when the deploy would stop.
A deploy without --dry-run runs the same dry run before it asks for
confirmation. Under the default --on-error stop, a plan with a refused
write stops the deploy before anything is applied.
Remove --dry-run when the plan is ready to apply. Keep --prune only when
the orphaned resources shown in the plan should be deleted.
Set the readiness timeout
Section titled “Set the readiness timeout”--timeout controls how long Kix waits for each resource to become ready. It
accepts minutes, seconds, or a bare number of seconds:
❱ kix deploy how-to-application --timeout 10m❱ kix deploy how-to-application --timeout 300s The default is three minutes. Increase it for resources whose normal startup takes longer, such as a database restore or a large image pull.
Some failures do not wait for the timeout. A pod in ImagePullBackOff or
CrashLoopBackOff, a Job that has used up its retries, or a custom resource
whose controller rejects it (a Cilium policy with Valid=False) fails the
resource as soon as Kix sees the state, with the controller’s message. The
owning package declares which states mean that; see
Declare readiness for custom resources.
An image pull fails at once only when another pull cannot succeed, for example when the image or tag does not exist, the registry refuses the login, or the image name is invalid. When the pull fails because of the network or the registry, such as a timeout, a reset connection, a 5xx answer, or a rate limit, the kubelet pulls again and Kix keeps waiting. If the timeout runs out first, the message shows the last pull error.
Kix also checks objects it does not change. Before it deploys an object, it
reads every unchanged object that the object depends on, directly or through
other unchanged objects, and waits for it to be ready under the same timeout.
An unchanged Deployment that is restarting is waited for like a changed one.
An unchanged object that an earlier deploy or a change on the cluster left
broken fails the deploy on that object, with its own status, and the error
says that nothing in this deploy changed it. Fix the object and deploy again,
or deploy with --on-error continue to deploy the objects that do not depend
on it. Unchanged objects that nothing in the deploy depends on are not read,
and a deploy with no changes reads nothing.
Every failure also says how many objects Kix did not deploy because they depend on the failed one.
Kix also stops a deploy after ten minutes with no progress. To change that
stall limit for one run, set KIX_STALL_TIMEOUT in seconds:
❱ KIX_STALL_TIMEOUT=900 kix deploy how-to-application Progress and readiness are separate: a resource can take longer than the
stall limit without triggering it when its readiness checks continue to
report activity. Kix tells you about such a wait anyway: after 10 seconds it
prints a waiting: line with the resource, what its last readiness check
said, and how much of the readiness timeout has passed, and repeats it at 30,
60, and 120 seconds and then every minute.
Choose when to prune
Section titled “Choose when to prune”By default, Kix reports resources that belonged to the previous activation
but keeps them. Use --prune to delete those orphans after the new resources
have been applied:
❱ kix deploy how-to-application --prune Pruning never deletes a Namespace or CustomResourceDefinition. It also keeps an orphan that another Kix cluster in the same Kubernetes cluster still deploys. The plan lists both as kept.
Right before deleting an orphan, Kix reads it again to make sure no other Kix
cluster deploys it. If something updates the object between that read and the
delete request (for example, an operator updating status), Kubernetes
rejects the delete and Kix retries up to 5 times. If all 5 attempts are
rejected, Kix leaves the object in place and fails the deploy with [K6315].
Kix also leaves orphans of this cluster in place when another object that
depends on them could not be deleted, or when their dependencies form a cycle.
The summary counts those remaining orphans as left on the cluster, and the
deploy exits 1. Resolve what blocked deletion, then run kix gc or
kix deploy --prune to remove them.
Kix waits for each pruned object to be removed from the cluster. It stops
waiting after --timeout passes without a finalizer being removed, or after 5
minutes in total. If an object is still on the cluster when the wait ends, the
deploy fails with [K2794]. Kix keeps any orphans that the build records as
dependencies of the stuck object, so the next kix deploy --prune or kix gc
can delete them once it is gone. When a package declares its operator as the
controller for its custom resources, Kix keeps the operator until those
custom resources are gone, and [K2794] reports whether the operator is ready.
Most packages do not declare a controller yet, so removing a custom resource
and its operator in the same deploy can delete the operator before it removes
the custom resource’s finalizer. If cleanup is still
running normally, deploy again later or pass a longer --timeout (up to 5m
per delete). See
When a delete does not finish
to resolve a stuck delete.
Use --skip-orphan-check to skip looking for orphans at all. The deploy
deletes nothing and does not list orphans, and they stay on the cluster for
kix gc
to find later:
❱ kix deploy how-to-application --skip-orphan-check Review stateful removals carefully. Kix requires a separate migration
acknowledgement when a plan replaces a stateful resource in the same logical
slot. This safeguard does not apply when a stateful resource is removed without
a replacement. Kix treats it as an ordinary orphan, and --prune deletes any
Kix-owned resources that left the build (including a PersistentVolumeClaim
declared directly as a Kix resource, though not claims that Kubernetes created
from a StatefulSet’s volumeClaimTemplates). The plan lists each orphan as
“will be deleted” before asking for confirmation. The --yes flag skips that
prompt.
Choose terminal or CI output
Section titled “Choose terminal or CI output”The default pretty format falls back to line-oriented output when stdin is
not a terminal. Colour is a separate decision and is disabled when stdout is
not a terminal. Select line explicitly for stable CI logs:
❱ kix deploy how-to-application --log-format line Use json when another program needs the deploy events. Stdout then holds
only the events, one JSON object per line; the plan and the other text go to
stderr. Every event carries schema_version, and the last is a summary
object with the counts and succeeded:
❱ kix deploy how-to-application --yes --log-format json > deploy-events.ndjson For a live dependency view in an interactive terminal, use the tui log
format. This example groups resources by namespace and caps the live
viewport at 20 rows with the KIX_TUI_HEIGHT environment variable:
❱ KIX_TUI_HEIGHT=20 kix deploy how-to-application --log-format tui --group-by namespace On a non-interactive terminal, --log-format tui falls back to line-oriented
output.
These output options change presentation only; they do not change deployment
order.
Troubleshoot a first-deploy preview
Section titled “Troubleshoot a first-deploy preview”A dry run persists nothing, so it cannot check an object whose Namespace or
CRD the same deploy creates. The plan lists those objects under “Not checked
by the dry run”, with their changes from comparing builds, and most of a
cluster’s first deployment is in that list. Run kix check for validation
before the first deploy, and review the listed objects in the plan.