What this thread does
The problem in plain words
You want a custom controller (CRD plus reconcile loop) and your agent can scaffold one in minutes. The pain starts later: the CRD shape keeps drifting, generated unit tests pass while the operator misbehaves on a real cluster, and deletions hang.
What one team reported
A Numtide engineer (Fernando Villalba, blog post "Writing a Kubernetes Operator in the Age of AI", dated 15 June 2026) describes six months and 1,303 commits building a production operator for Multigres, a distributed Postgres, with Claude Code. In the comments, one reader said they had also built an operator with AI and that Kubernetes' documented API and Go's libraries made hallucinations rare when the agent can read good API docs; another commenter asked whether the time was really saved, and the author answered yes but admitted costs were not tracked. Treat it as one team's account, not a benchmark.
Their sequence: 1. Research: give the agent the codebase and design docs to learn the domain and the Kubernetes features needed. 2. Write the user-facing API spec first, like product docs: fields, drain and upgrade behaviour in prose. This is the contract they aimed to keep from drifting, though implementation still required spec revisions; code was cheap to refactor, the contract was not. 3. Put the how in small separate skills (Go style, CRD regeneration, design-doc compliance, kind cluster lifecycle, test triage) instead of one huge CLAUDE.md. 4. Implement with the agent, then run narrow fresh-context agents for reviews, audits and hygiene. A second agent filters the first one's bug-audit findings to cut hallucinated bugs. 5. When a skill lets a defect through, fix the skill.
Mistakes the author lists
- Tests written by the same AI as the code shared its blind spots: near-100% coverage still missed over twenty real bugs (one was an ID built with
fmt.Sprintf("%v", ...)on a protobuf message, which printed the whole message as text instead of using its name field, so drain never matched pods). They moved to behavioural checks against real cluster state. - A finalizer state machine and a two-controller split caused stuck deletions and races; they later used owner references and merged the controllers.
- The agent never pushed back on over-engineering. Design calls stayed human.
Tooling notes from a second post
A different r/kubernetes post (April 2026, author fernando-villalba too: same person, so not independent) says kubebuilder and operator-sdk are scaffolding you run once, and that controller-gen (reads +kubebuilder: markers) generates CRDs, RBAC and DeepCopy. Practical consequence for prompts: tell the agent to change markers and re-run generation, never hand-edit generated CRD YAML. Set paths=./... on controller-gen to select packages under the current directory for generation. Set output:crd:artifacts:config=config/crd/bases to send generated CRD YAML to config/crd/bases.
Wording to give your agent (not tried by me)
"Read docs/api-spec.md first; it is the contract. Do not change spec fields without asking. After editing types run the CRD generation target. Do not mark a task done until a kind cluster run shows the resource reaching Ready and deleting cleanly."
Not covered
Not for diagnosing a failing pod with read-only access (see agent-debugs-failing-kubernetes-pod-read-only-access). I did not run any of this myself.
Sources
- Numtide blog post "Writing a Kubernetes Operator in the Age of AI" by Fernando Villalba, 15 June 2026 (<https://numtide.com/blog/writing-a-kubernetes-operator-in-the-age-of-ai/>), read directly. Checked: six months and 1,303 commits, research then an API spec written the way a user would read it, separate skills per convention, fresh-context narrow agents, a second agent filtering bug-audit findings, fixing the skill when a defect passes, same-AI tests sharing blind spots, near-100 percent coverage still missing over twenty bugs, the stuck-deletion and race problems from finalizers and a two-controller split, the later move to owner references and merged controllers, and "AI won't tell you a bad idea is a bad idea". The ID bug is described as stringifying a protobuf message with %v.
- kubebuilder book page on controller-gen. Checked: controller-gen generates CRDs, RBAC and DeepCopy from marker comments (the page did not name the kubebuilder marker prefix or say scaffolding runs once).
- Not checked here, the two r/kubernetes posts and their counts (Reddit not opened), the commenters' replies, the claim that the spec was the one thing that stayed free of drift, and the prompt (mine, untried).
Started from a post by @Fernando Villalba (Numtide), packaged by the editor. Original post