✦ For everyone, free.

Practical knowledge for real and everyday life

Home

Kubernetes Declarative Drift

Kubernetes Declarative Drift refers to the gradual divergence between the desired state and actual cluster state over time.

Kubernetes Declarative Drift is the divergence that accumulates between a cluster's actual live state and the state described by its version-controlled manifests, arising whenever changes are made to the cluster through a path other than the declared source of truth — a manual kubectl edit, an ad hoc patch applied during an incident, or a controller adjusting a field the manifest never accounted for — leaving the manifest an increasingly inaccurate description of what the cluster actually looks like. Drift is the direct enemy of the declarative state model's core promise, since a manifest that no longer matches reality can no longer be trusted as an authoritative description of desired state.


How Drift Accumulates

Manual Interventions Outside the Declared Path

The most common source of drift is a manual change made directly against the live cluster during troubleshooting or an incident — scaling a Deployment up temporarily, patching a resource limit under pressure, editing a ConfigMap directly — made with the intention of being temporary but never reconciled back into the manifest that is supposed to represent the object's true desired state.

Legitimate External Actors Writing to the Same Fields

Drift can also arise from entirely legitimate automated actors, such as an autoscaler adjusting replica count or a certificate manager updating a Secret's contents, whose changes are correct and expected but which a manifest not designed with those actors in mind will attempt to overwrite on its next apply, producing a form of drift that manifests as repeated flapping rather than a one-time divergence.

Configuration Applied Through Multiple Uncoordinated Paths

In organizations where more than one team or tool applies changes to overlapping resources without coordinated field ownership, drift emerges from the interaction between those uncoordinated writers, each correct in isolation but collectively producing a live state that no single manifest fully or accurately describes.


Consequences of Unmanaged Drift

The Manifest Becomes an Unreliable Source of Truth

Once drift accumulates, reapplying the existing manifest can either silently fail to restore the intended state (if the manifest never captured certain fields to begin with) or unexpectedly revert an intentional live change the manifest author was unaware of, undermining confidence in the manifest as an accurate description of the system.

Disaster Recovery and Rebuild Risk

Drift is especially dangerous for disaster recovery scenarios: if a cluster is lost and rebuilt purely from its manifest repository, any drifted state that was never captured back into the manifests is permanently lost, meaning the rebuilt cluster does not actually match what was running before the loss, often surfacing only when the rebuilt system behaves unexpectedly compared to what operators remembered.


Detecting Drift

Continuous Diffing Against Live State

GitOps tooling and dedicated drift-detection systems continuously compare a cluster's live object state against the manifests stored in the designated source repository, surfacing any field-level divergence as an alert or dashboard indicator, turning drift from a silent, gradually accumulating problem into a visible, actively tracked one.

Reconciliation Loops as Passive Drift Correction

Because GitOps controllers actively reconcile live state back toward the repository's declared state on an ongoing basis, they function as a continuous drift-correction mechanism, automatically reverting manual changes that were never reflected back into the source manifests, which is precisely the behavior that makes ad hoc live changes in a GitOps-managed cluster short-lived unless the manifest itself is also updated.


Managing Drift Deliberately

Reconciling Intentional Drift Back Into Source

When a manual change is genuinely intended to persist, the correct response to drift is to update the source manifest to reflect it as soon as practical, restoring the manifest's accuracy rather than leaving the live cluster as the only record of the change.

Designing Manifests to Accommodate Expected External Writers

For fields legitimately managed by another actor, the durable fix for recurring drift is excluding those fields from the manifest entirely (an application of manifest field ownership discipline), rather than repeatedly reasserting a value the manifest was never meant to own, converting a source of conflict into a stable, understood division of responsibility.