kubernetes-operator

kubernetes-operator is a skill for Claude Code, Codex from tmj-90/gaffer. It costs 74 tokens per session (972 once invoked), scanned A, original, Apache-2.0.

Guidance for building a Kubernetes Operator, a controller that repeatedly makes a cluster match the desired configuration in a custom resource. It focuses on reconciliation, cleanup, retries, status, and permissions.

In plain words
What is it for?
Designing custom resources and reconcile loops, and building Operators with tools such as controller-runtime, Kubebuilder, or Operator SDK.
Why use it?
It helps avoid common controller errors such as missing cleanup steps, stalled retries, incorrect status updates, and excessive access rights.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/tmj-90/gaffer/kubernetes-operator
Any agent
npx skills add tmj-90/gaffer --skill kubernetes-operator
Clone the repo
git clone --depth 1 https://github.com/tmj-90/gaffer

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for kubernetes-operator

README.md
[![agentmods](https://agentmods.dev/badge/skills/tmj-90/gaffer/kubernetes-operator.svg)](https://agentmods.dev/skills/tmj-90/gaffer/kubernetes-operator)
Your own site
<a href="https://agentmods.dev/skills/tmj-90/gaffer/kubernetes-operator"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/kubernetes-operator.svg" alt="Measured on agentmods" height="20"></a>
Per session 74 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 972 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00074 $0.00972
Opus 5 $0.00037 $0.00486
Sonnet 5 $0.00015 $0.00194
Haiku 4.5 $0.00007 $0.00097

Measured 5d ago against content hash 3cc7256722f7, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

kubernetes-operator scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

runner/skills/kubernetes-operator/SKILL.md · 69 lines

How it starts

The opening of the file, as written. The whole thing — 69 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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

Bug Prevention
Blocking HTTP calls in reconcile Use async clients or move to a goroutine
No requeue on transient error Always return ctrl.Result{}, err for transient; RequeueAfter for polling
Missing finalizer Add finalizer on creation; remove only after cleanup complete
Mutating spec instead of status Spec is user-owned; status is controller-owned
No status subresource Status updates without subresource trigger spec reconcile → loop
RBAC over-grant Principle of least privilege; use ClusterRole only when namespace-scope is insufficient
No leader election Multi-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.

Read the full file on GitHub · 69 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 69 lines · 74 tokens per session scan A 3cc7256722f7

Subscribe to this mod's changes

kubernetes-operator is a skill published in the GitHub repository tmj-90/gaffer (2 stars, last pushed 5d ago), licensed Apache-2.0. It adds 74 tokens to every session and 972 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.