Drift
What counts as drift and what does not, how Wardn finds it, and the three things you can do about it.
Drift is a difference between the snapshot a deployment runs and what the cluster now has: someone ran kubectl edit, a script patched a Deployment, an object was deleted by hand. Wardn reports it, and you decide what to do. It never changes the cluster because of drift unless you turn on a drift policy for that deployment.
Why drift is hard to get right
A naive comparison of the manifest with the live object reports changes nobody made: defaults the API server filled in, 1000m stored as 1, a sidecar a webhook injected, replicas an autoscaler set. A drift view full of these trains people to ignore it, and then it misses the real change. So the question Wardn answers is narrower: did anyone change a field that Wardn owns?
How detection works
The operator compares the live objects with the snapshot it last applied, using a server-side dry run of the same apply. Only fields Wardn owns can differ. A difference is confirmed with a second look a couple of seconds later, so a controller writing at that instant does not show up.
| Case | Drift? |
|---|---|
| Someone edits a field Wardn applied | Yes |
| An object in the snapshot was deleted by hand | Yes, reported as added: it is in the snapshot and not running |
An autoscaler changes spec.replicas, and your manifest leaves the field out | No: another controller owns it |
The same, but your manifest sets spec.replicas | No, when a HorizontalPodAutoscaler in the namespace targets the workload, or the workload carries the label drift.wardn.dev/hpa-managed: "true": Wardn skips /spec/replicas for it. Applying the manifest still writes your replicas back, so leave the field out of the manifest. See Ignore autoscaler fields. |
| A mutating webhook injects a sidecar | No |
| The API server fills in defaults | No |
| Status fields written by controllers | No |
| An object Wardn never applied | No |
Detection reports on every deployment, including ones that only observe. An empty list means no drift. A deployment's state shows the number of drifted objects, and the Drift tab lists the objects and the fields of each. The Live diff tab shows the live value against the snapshot's value.
Wardn's own tests apply a corpus of awkward real-world manifests to a real cluster, with an autoscaler, a mutating webhook and a controller writing status, and require zero reported drift.
Three actions
For each drifted object you choose, and every choice is recorded in Activity.
| Action | Use it when | What happens | Permission |
|---|---|---|---|
| Revert | The cluster is wrong. | Wardn queues the running snapshot to be applied again. Server-side apply changes only what differs. You can revert one object or everything that drifted; the apply covers the whole snapshot. | drift:revert |
| Adopt | The cluster is right and git is wrong. | Wardn records the exact JSON patch (RFC 6902) that turns the snapshot's object into what the cluster runs. | drift:adopt |
| Ignore | The difference is expected and permanent. | A standing rule for one object and one JSON pointer, such as /spec/replicas, including everything below it. The drift is not reported again. | drift:ignore |
cluster differs ──▶ revert the cluster goes back to the snapshot
├─▶ adopt you take a patch to git; Wardn waits for you to say merged or dismissed
└─▶ ignore a rule: never report this field again, with a reasonAdopt is deliberately not automatic. Wardn does not push to your repository. You carry the patch into git yourself, then record the outcome as merged or dismissed. A Secret cannot be adopted, because its values are masked.
The drift policy
A deployment's drift policy decides what happens without a person:
| Mode | Behaviour |
|---|---|
| Detect only | Record and show drift. |
| Revert after | Revert what still differs a set time after it was found (15 minutes, 1 hour, 4 hours or 1 day in the web app). |
| Revert at once | Revert as soon as drift is found. |
An automatic revert is the same revert action, run by Wardn and recorded in Activity. A deployment that only observes only detects.
Where drift shows up
- Deployments list and page: a drift count next to sync and health.
- Drift and Live diff tabs: the objects, fields and values.
- Activity: the actions (revert, adopt, ignore) and who took them.
- Timelines: the churn that causes drift, such as restarts and changes, is in the cluster's and the deployment's timeline, not Activity.
Guides that use this
- Drift: detect, revert, adopt and ignore, in the web app and the API.
- Ignore fields an autoscaler owns.
- Recover from a bad change.