A cluster twin where the agent breaks things first
Before an agent applies a fix in production, it applies it to a copy of the cluster's API state with live controllers and shows a human the diff of the consequences.
Problem #
AI agents for operations are already decent at finding the cause: they read events, logs and conditions and match them against known bugs. The trouble starts at the “now let’s fix it” step. The agent proposes removing a finalizer, editing a claimRef or deleting a “stuck” object, and a human has to take it on faith that the consequences stop at that object.
In Kubernetes they almost never stop there. Remove a finalizer and the garbage collector deletes the child objects. Change a label and it turns out another controller reads it, one nobody remembered. --dry-run=server honestly checks admission and the schema, but says nothing about what the controllers will do a second after the write. A convincing plan and a successful dry-run do not prove the mechanism is correct.
The people who suffer are those who already run agents in operations or want to: platform teams and providers, where a single mistake in a shared cluster hits many tenants.
Why now #
Agents that can run kubectl have become commonplace, and the question has shifted from “will it find the cause” to “can we give it write access”. Meanwhile all the building blocks for a twin are already upstream: kwok simulates nodes and pods at almost zero cost, an apiserver and etcd come up in a container in seconds, and most controllers have flags to run against an arbitrary kubeconfig.
Why it’s cool #
The unfair advantage is that the twin runs the real controllers, not a model of their behavior. We take a snapshot of objects from production, bring up an empty apiserver next to it, load the objects while preserving ownerReferences and finalizers, and start kube-controller-manager and the required operators at the same versions. kwok plays the nodes and pods. Then the agent executes its plan in the twin, we wait for everything to reconcile, and take a diff: which objects were deleted, created or modified, and by which controller (managedFields shows this beautifully).
What goes to the human for approval is not “I will remove the finalizer” but “after this, GC will delete 14 PVCs in namespace X, here is the list”. That is a completely different conversation.
How to build it #
Stack: Go, controller-runtime, kwok, etcd, kube-apiserver of the matching version.
- Snapshot. A read-only export of the relevant namespaces and cluster-scoped resources via LIST, without secrets (they are replaced with stubs that keep the same keys). Controller versions and images are recorded separately.
- Bringing up the twin.
kwokctl create clusterwith the right version, then restoring objects in dependency order: CRDs, namespaces, owners, then dependents. UIDs change, soownerReferencesare rewritten from a mapping table. - Controllers. First only the built-in ones (GC, namespace, deployment, statefulset), then operators from an allow-list, launched against the twin’s kubeconfig.
- Running the plan. The agent works through an MCP tool
twin_apply, which accepts the same set of commands that will go to production. - Diff. Comparing state before and after, grouped by the controller that made the change, with a Markdown report.
First slice in 2–3 weeks: built-in controllers only and the scenarios “remove a finalizer”, “delete an object”, “change a label”. That alone is enough to catch the nastiest GC cascades.
Who has tried #
- HolmesGPT (CNCF Sandbox, started at Robusta) and K8sGPT diagnose and explain. They don’t try to predict the consequences of a write; that is a different layer.
- kwok and vcluster give you a cheap cluster, but they can’t turn production into a twin on their own and don’t compute a diff of consequences. Here they are building material.
kubectl diffand--dry-run=servercheck only the request itself, without the controllers’ reaction.
First customers #
Platform teams that have already let agents in read-only and hit the question of write access. Managed Kubernetes providers, whose on-call engineers also regularly fix other people’s clusters by hand. And, if you ask me, the agent developers themselves: they need a gate like this to sell “auto-remediation” to anyone serious.
What kills it #
The twin lies wherever behavior depends on the outside world: cloud APIs, CSI, real nodes and the network. If those matter most to a customer, the value drops to “we checked GC”, and that is a harder sell. On top of that, operators that don’t tolerate running outside their own cluster will have to be patched one by one, and that zoo could eat the whole budget. And finally, if the big agent vendors build a similar sandbox into their products, a standalone product becomes a feature.