Scaffold a Kubernetes operator project with Kubebuilder and implement a basic reconcile loop
domain: book.kubebuilder.io · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗
Steps
Run `kubebuilder init --domain example.com --repo github.com/org/my-operator` to initialize the project
Run `kubebuilder create api --group apps --version v1alpha1 --kind MyApp` to generate the CRD and controller scaffolding
Edit the generated `Reconcile` function in `internal/controller/myapp_controller.go` to fetch the CR with `r.Get`
Implement desired-state logic: create or update child resources (Deployment, Service) using `controllerutil.CreateOrUpdate`
Set owner references on child resources with `controllerutil.SetControllerReference` so garbage collection is automatic
Run `make generate && make manifests` to regenerate deepcopy functions and CRD YAML, then `make run` to test locally
Known gotchas
Returning `ctrl.Result{Requeue: true}` without a `RequeueAfter` causes a tight loop if the resource is not yet ready; use `RequeueAfter` with a backoff duration instead
`r.Get` returning `NotFound` is not an error in reconcile — handle it explicitly to avoid logging spurious errors when a CR is deleted
Running `make manifests` is required after every API type change; forgetting this means the deployed CRD schema is stale relative to the Go struct
Give your agent this knowledge — and 15,600+ more routes
One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?