Kubebuilder Operator Build
Build a Go operator with kubebuilder: CRD types and markers, an idempotent reconcile loop, finalizers, RBAC, and envtest.
Before & after
Same prompt, same agent — the only difference is the skill.
Kubernetes is powerful but complex. You'll want to think about how to structure your application deployment—things like pods, services, ingress, and volumes. Using operators can help automate repetitive tasks and make your cluster more manageable. You could start by writing a basic deployment manifest, testing it locally with Minikube, then gradually add more sophistication. The key is to understand your application's needs and how they map to Kubernetes resources. There are many tools and frameworks that can help, so it might be worth exploring what's available. Let me know if you'd like help thinking through your specific architecture.
KUBERNETES OPERATOR DEPLOYMENT
CUSTOM RESOURCE DEFINITION (CRD)
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: appdeployments.mycompany.io
spec:
group: mycompany.io
names:
kind: AppDeployment
scope: Namespaced
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
properties:
spec:
properties:
replicas: {type: integer}
image: {type: string}
env: {type: array}
OPERATOR WORKFLOW (Pseudo-code)
1. Watch AppDeployment resources in cluster
2. On create: generate Deployment, Service, PVC manifests
3. On update: reconcile desired state (scale replicas, update image)
4. On delete: cascade cleanup (keep PVC for data safety)
5. Health probe: restart pods on 3 failed liveness checks
DEPLOYMENT CHECKLIST
✓ Operator container: published to registry.mycompany.com:latest
✓ RBAC: operator SA has get/list/watch/patch on Deployments, Services, PVCs
✓ Leader election: enabled (single operator instance safe)
✓ Finalizers: protect PVC deletion (manual approval required)
✓ Webhooks: validate AppDeployment spec (image must be tagged, replicas 1-10)
EXAMPLE: Create instance
kubectl apply -f - <<EOF
apiVersion: mycompany.io/v1
kind: AppDeployment
metadata:
name: myapp
spec:
replicas: 3
image: myregistry.com/myapp:v1.2.0
env:
- name: DB_HOST
value: postgres.default.svc.cluster.local
EOF
Status: Operator creates 3 pods, 1 service, routes traffic automaticallyAbout this skill
Go from 'we need a controller for this' to a running, tested operator. The skill gives you exact kubebuilder commands and controller-runtime code, with a make target that verifies each stage.
What it does
- Scaffolds the project and API with kubebuilder
- Defines spec and status types with validation, default, printcolumn, and CEL immutability markers
- Writes a level-triggered reconcile loop: fetch, finalizer handling, owned children via CreateOrUpdate and owner refs, and status conditions with ObservedGeneration
- Generates least-privilege RBAC and optional webhooks
- Tests create, update, status, and delete paths with envtest, then runs locally and deploys
What you get
A working operator plus a summary of the API, reconcile flow, owned resources, finalizer behavior, RBAC, verification results, and known limits.
Best for
Platform and infrastructure engineers writing Go operators for internal platforms or products.
SKILL.md preview
---
name: kubebuilder-operator-build
description: Build a working Kubernetes operator in Go with kubebuilder and controller-runtime - scaffold the project, define the CRD types with validation markers and a status subresource, write an idempotent reconcile loop with owner references, finalizers, and status conditions, generate RBAC, and prove it with envtest. Use when the user says "build an operator for X", "scaffold a controller", "write the reconcile loop", "add a finalizer", or has a CRD design and needs the code, including casual asks like "why does my reconcile loop keep firing", "how do I set owner refs on this Deployment", or "my finalizer never gets removed".
---
… (sign up to view the full skill)More development skills
View all Development skills →Chaos Experiment and Game Day Planner
Plans chaos experiments and game days: hypothesis, blast radius, abort conditions, tool manifests, rollback, and post-run review.
Claude Code Cost and Latency Routing
Configure Claude Code Router with model tiers, explicit fallbacks, compatibility checks, and a cost-aware validation plan.
CI/CD Pipeline Builder with Gated Deploys
Generates CI/CD workflows from your repo's real stack: cached fast-fail checks, pinned actions, and staging-to-prod deploys with gates.
Terraform Modules and Safe Deployments
Get reusable Terraform modules, safe state migrations, explicit provider wiring, and CI gates tied to reviewed plans.