Skip to content
Install the CLI

How-to guide Operate a cluster

Reconcile drift

Use kix deploy --reconcile to reapply every desired resource, including resources whose activation identity has not changed. Add --force-conflicts only when you have reviewed fields owned by another manager and intend Kix to take them back.

Start by identifying the fields that changed:

kix-examples/
❱ kix drift
Connecting to cluster...
17 kix-managed resources

  ✓ Activation/how-to-application-6rhi3wpk9iml         in sync
  ✓ ConfigMap/preview@how-to-app                       in sync
  ✓ ConfigMap/production@how-to-app                    in sync
  ✓ ConfigMap/production-health-script@how-to-app      in sync
  ✓ CustomResourceDefinition/activations.kix.run       in sync
  ✓ CustomResourceDefinition/packageinstances.kix.run  in sync
  ✓ Deployment/preview@how-to-app                      in sync
  ✗ Deployment/production@how-to-app                   DRIFTED
      spec.replicas taken by kubectl (Update via /scale) at unknown time
  ✓ Job/production-health@how-to-app                   in sync
  ✓ Namespace/how-to-app                               in sync
  ✓ Namespace/kube-system                              in sync
  ✓ PackageInstance/preview@how-to-app                 in sync
  ✓ PackageInstance/production@how-to-app              in sync
  ✓ PackageInstance/platform-dns@kube-system           in sync
  ✓ PackageInstance/platform-storage@kube-system       in sync
  ✓ Service/preview@how-to-app                         in sync
  ✓ Service/production@how-to-app                      in sync

Drift: 16 in sync, 1 drifted
(exit code: 1)

Confirm that the checked-in cluster definition still describes the state you want. Reconciliation applies that definition, so review intentional emergency changes before continuing.

The example drift report attributes spec.replicas to kubectl. Reapply the cluster and deliberately take ownership of that field:

kix-examples/ live capture
❱ kix deploy how-to-application --reconcile --force-conflicts -y
Show outputHide output · 58 lines
Building cluster 'how-to-application'...
Cluster how-to-application: 17 manifests
Connecting to cluster...
Active activation: how-to-application-6rhi3wpk9iml (6rhi3wpk...)

  how-to-app
    ~ production 1.0.0 (2 changed)

  Plan: 1 updated, 3 unchanged
  Resources: 2 real content, 0 dep-affected
  ↻ 1 under the rerun rule (deleted first when live): Job/production-health@how-to-app

Drift: 1 field differs live from the deployed build:
  ↺ Deployment/production@how-to-app spec.replicas: 1 live, 2 deployed, set by kubectl
      the deploy puts the deployed value back

Not checked by any preview: whether Pods start, pull their images, and pass their probes.

Objects: 17 written, 0 deleted (sha256:0259ef15fef8d74b8e97783aa5ecce1e719dd93ce351b4ef1561e5cd7d9017e3)
  ↻ 17 written again unchanged: a build this cluster ran holds the same file
plan: 17 nodes
  ~ Namespace/kube-system configured
  ✔ Namespace/kube-system ready
  ~ Namespace/how-to-app configured
  ✔ Namespace/how-to-app ready
  ~ CustomResourceDefinition/packageinstances.kix.run configured
  ~ CustomResourceDefinition/activations.kix.run configured
  ~ ConfigMap/production@how-to-app configured
  ✔ ConfigMap/production@how-to-app ready
  ~ ConfigMap/production-health-script@how-to-app configured
  ✔ ConfigMap/production-health-script@how-to-app ready
  ✔ CustomResourceDefinition/packageinstances.kix.run ready
  ~ ConfigMap/preview@how-to-app configured
  ✔ CustomResourceDefinition/activations.kix.run ready
  ✔ ConfigMap/preview@how-to-app ready
  ~ Deployment/preview@how-to-app configured
  ~ Deployment/production@how-to-app configured
  ✔ Deployment/preview@how-to-app ready
  ~ Service/preview@how-to-app configured
  ✔ Service/preview@how-to-app ready
  ~ PackageInstance/platform-storage@kube-system configured
  ~ PackageInstance/platform-dns@kube-system configured
  ✔ PackageInstance/platform-storage@kube-system ready
  ✔ PackageInstance/platform-dns@kube-system ready
  ~ PackageInstance/preview@how-to-app configured
  ✔ PackageInstance/preview@how-to-app ready
  ✔ Deployment/production@how-to-app ready
  ~ Service/production@how-to-app configured
  ✔ Service/production@how-to-app ready
  + recreate Job/production-health@how-to-app created
  ↻ Job/production-health@how-to-app ran again (changed since the last run)
  ~ PackageInstance/production@how-to-app configured
  ✔ PackageInstance/production@how-to-app ready
  ~ Activation/how-to-application-6rhi3wpk9iml configured
  ✔ Activation/how-to-application-6rhi3wpk9iml ready
  • activation 'how-to-application-6rhi3wpk9iml' → Active

Deploy complete: 1 created, 16 configured, 0 unchanged, 0 failed

The example begins with a production Deployment that was scaled from two replicas to one outside Kix. Reconciliation reapplies the rendered resources and waits for them to become ready.

Use --context and --flake when the Kubernetes target or source directory is not the current one:

❱ kix deploy how-to-application --reconcile --force-conflicts -y --flake ./infrastructure --context kind-kix-demo

Omit -y when running interactively if you want to review the confirmation prompt.

Run the drift check again:

kix-examples/
❱ kix drift
Connecting to cluster...
17 kix-managed resources

  ✓ Activation/how-to-application-6rhi3wpk9iml         in sync
  ✓ ConfigMap/preview@how-to-app                       in sync
  ✓ ConfigMap/production@how-to-app                    in sync
  ✓ ConfigMap/production-health-script@how-to-app      in sync
  ✓ CustomResourceDefinition/activations.kix.run       in sync
  ✓ CustomResourceDefinition/packageinstances.kix.run  in sync
  ✓ Deployment/preview@how-to-app                      in sync
  ✓ Deployment/production@how-to-app                   in sync
  ✓ Job/production-health@how-to-app                   in sync
  ✓ Namespace/how-to-app                               in sync
  ✓ Namespace/kube-system                              in sync
  ✓ PackageInstance/preview@how-to-app                 in sync
  ✓ PackageInstance/production@how-to-app              in sync
  ✓ PackageInstance/platform-dns@kube-system           in sync
  ✓ PackageInstance/platform-storage@kube-system       in sync
  ✓ Service/preview@how-to-app                         in sync
  ✓ Service/production@how-to-app                      in sync

Drift: 17 in sync

The drifted count should be zero. You can also use kix status to confirm that the reapplied workloads are ready.

--reconcile deliberately reapplies all desired resources. --force-conflicts also takes fields from other server-side apply managers. Use a normal kix deploy when you only need to deploy a new rendered activation.