agentsclimarketplace

Kubernetes operator

Skill tmj-90/gaffer/runner/skills/kubernetes-operator

Use when building a Kubernetes Operator — custom controllers that reconcile CRD state. Triggers on "build an operator", "CRD design", "reconcile loop", "controller-runtime", "kubebuilder", "operator-sdk", "custom resource", or "operator capability levels". NOT a generic k8s skill — specifically the Operator pattern.From its SKILL.md

Install
npx -y skills add tmj-90/gaffer --skill kubernetes-operator

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

4.2 KB, 882 tokens by cl100k_base, as published. Nobody here has run it

Build operators that reconcile correctly

An operator is a reconcile loop, not a script. Most operator bugs are not Kubernetes bugs — they are reconcile-loop bugs: missing finalizers, blocking calls, no requeue on transient errors, status drift, RBAC over-grants.

The reconcile mental model

observe(actual) → desired = read(spec) → diff(actual, desired) → act → update(status)
                                                                         ↓
                                                                  requeue / done

Idempotent, not imperative. The reconcile function must be callable any number of times with the same outcome. It must not assume what happened on the previous call.

Common operator bugs

BugPrevention
Blocking HTTP calls in reconcileUse async clients or move to a goroutine
No requeue on transient errorAlways return ctrl.Result{}, err for transient; RequeueAfter for polling
Missing finalizerAdd finalizer on creation; remove only after cleanup complete
Mutating spec instead of statusSpec is user-owned; status is controller-owned
No status subresourceStatus updates without subresource trigger spec reconcile → loop
RBAC over-grantPrinciple of least privilege; use ClusterRole only when namespace-scope is insufficient
No leader electionMulti-replica deploy without leader election → split-brain

Operator capability levels (OLM)

Level 1 (Basic install) → Level 2 (Seamless upgrades) → Level 3 (Full lifecycle) → Level 4 (Deep insights) → Level 5 (Auto pilot)

Start at Level 1 and promote only when the lower levels are tested and stable.

Steps

  1. Read the lore + existing operators. search_lore for CRD conventions, RBAC policy, and framework choice. Match the existing toolchain (kubebuilder vs operator-sdk vs KOPF vs metacontroller).
  2. Design the CRD API surface. spec = desired state (user-owned); status = observed state (controller-owned). Define conditions as standard status fields. Validate with admission webhooks for types that have invariants.
  3. Implement the reconcile loop. Read → diff → act → update status. Every return is either Result{}, nil (done, no requeue) or Result{}, err / Result{RequeueAfter: d}, nil (retry/poll).
  4. Add finalizers. Register on object creation; execute cleanup in the finalizer block; remove only after cleanup succeeds.
  5. RBAC. Generate from controller-gen annotations; scope to namespace where possible; document every ClusterRole grant.
  6. Leader election. Enable for any operator that will run with >1 replica.
  7. Verify. Deploy to a local cluster (kind/minikube); create/update/delete a CR; confirm status conditions reflect the current state; test error injection (unavailable dependency); record evidence.

Build / Test

  • go vet + golangci-lint clean.
  • Unit tests for the reconcile function with a fake client — test every return path.
  • E2E tests against a real cluster (kind): create, update (in-place upgrade), delete with finalizer cleanup.
  • controller-gen generates CRD + RBAC manifests — commit generated files, do not hand-edit them.

Review checklist

  • Reconcile is idempotent — safe to call N times with the same result.
  • Every error path requeues — transient errors return err; expected polls use RequeueAfter.
  • Finalizer present — and cleanup is tested on deletion.
  • Status uses conditions — standard Kubernetes condition format (Type, Status, Reason, Message).
  • RBAC minimal — no ClusterRole without justification; generated by controller-gen.
  • Leader election enabled for multi-replica deploys.

Capture lore

Framework choice, CRD naming conventions, cluster version, and RBAC policy are high-value lore — call suggest_lore with tags: [kubernetes, operator, crd].

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,834. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.