How-to guide / Operate a cluster
Reconcile drift
These docs describe Kix's main branch, which can include changes not yet released. Read the docs for the latest release.
A standard kix deploy heals out-of-band changes automatically. It recreates
any resource in the build that is missing from the cluster or being deleted,
and it restores fields that another writer changed on a Kix-applied resource,
taking ownership back from that field manager. kix plan marks those resources
as changed on the cluster before anything is applied. Pass --reconcile only
when you want Kix to reapply every resource in the build regardless of whether
it changed.
Review what changed
Section titled “Review what changed”Start by finding the objects that changed and the fields that changed on them:
❱ kix status how-to-application --check drift 1...2how-to-app/production3 Deployment how-to-app/production changed since deploy (spec.replicas by kubectl)4
516 resources: 15 ok, 1 changed.6Next: run `kix deploy how-to-application` to restore what is missing or changed, or `kix plan how-to-application` to preview the changes first. The deploy takes back the fields that kubectl owns.Run kix plan how-to-application to preview what the deploy will change. The
plan counts drifted resources on a ↺ line and lists each modified field and
its current field manager under Drift:.
Confirm that the checked-in cluster definition still describes the state you want. Reconciliation applies that definition, so review intentional emergency changes before continuing.
Reapply the desired resources
Section titled “Reapply the desired resources”The example output shows that kubectl changed spec.replicas. Deploy the
cluster to restore the field and take ownership back:
❱ kix deploy how-to-application -y 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
~ production 1.0.0 (1 changed)
Plan: 1 updated, 3 unchanged
Resources: 1 changed in content, 0 tracking annotation only (no spec change or restart)
Drift: 1 field(s) on the live cluster differ from the deployed build:
↺ Deployment.apps/production@how-to-app spec.replicas: 1 live, 2 in deployed build, set by kubectl
this deploy overwrites the field and takes ownership back from kubectl; if kubectl should keep owning it, list the field in `ownership.cede`
Not checked by any preview: whether Pods start, pull their images, and pass their readiness probes.
Objects: 1 to write, 0 to delete (sha256:c428c1cefcceb4396c15e23ec0b8622de07403c75dd495229c12d50a4c88f471)
↺ 1 object(s) changed on the cluster since Kix applied them; this deploy restores the build's values and takes back fields modified by other field managers
plan: 15 nodes
~ Deployment.apps/production@how-to-app configured
✔ Deployment.apps/production@how-to-app ready
• activation 'how-to-application-6n94gibgl7zv' → Active
Deploy complete: 0 created, 1 configured, 14 unchanged, 0 failed The example begins with a production Deployment that was scaled from two
replicas to one outside Kix. kix deploy reapplies that Deployment with force
and waits for it to become ready, leaving unchanged resources untouched.
Use --context and --flake when the Kubernetes target or source directory
is not the current one:
❱ kix deploy how-to-application -y --flake ./infrastructure --context kind-kix-demo Omit -y when running interactively if you want to review the confirmation
prompt.
Confirm the result
Section titled “Confirm the result”Run the drift check again:
❱ kix status how-to-application --check drift 1...216 resources: 16 ok.No object should be changed, and the command exits 0. Run kix status
without --check to also confirm that the reapplied workloads are ready. See
Check a cluster’s status.
Fields listed in ownership.cede never count as changed, so kix deploy
leaves them with the controller that owns them. Kix also never forces fields
away from another Kix cluster. If two Kix clusters set different values for the
same field, the deploy stops with [K5636]. --reconcile reapplies every
resource in the build, and --force-conflicts forces field ownership on every
apply. Neither flag is needed to heal drift.