Skip to content
Skillpedia
Deploy & cloud (DevOps)29k Β· #9564

kubernetes-operator

What it does

It guides the design and checking of Kubernetes operators, which are programs that manage custom resources in a cluster. It is for engineers building or auditing this kind of controller.

When to use it

  • βœ“When you are building a new Kubernetes operator for a custom resource.
  • βœ“When you want an existing operator reviewed for missing finalizers, status drift or permission problems.
  • βœ“When you need to choose a framework such as kubebuilder or operator-sdk.

Skill link

https://github.com/alirezarezvani/claude-skills/blob/main/engineering/kubernetes-operator/skills/kubernetes-operator/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/alirezarezvani/claude-skills/blob/main/engineering/kubernetes-operator/skills/kubernetes-operator/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œI want to build a Kubernetes operator that manages our database backups. Help me design it before I write the controller.”

5 new skills a week. 1 minute to read.

How it works

The agent validates the resource definition, lints the control loop for common bugs, and scores the operator's maturity level using helper scripts.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Kubernetes Operator

Build operators that reconcile correctly. 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. This skill catches them deterministically before they reach a cluster.

When to use

  • Building a new Kubernetes Operator (controller for a CRD)
  • Reviewing an existing operator for capability-level gaps
  • Auditing a CRD spec for status/conditions/finalizer correctness
  • Choosing a framework (controller-runtime / kubebuilder / operator-sdk / metacontroller / KOPF)
  • Designing the API surface of a Custom Resource
  • Hardening RBAC, leader election, or webhook validation

When NOT to use

  • Plain Helm chart packaging β†’ use helm-chart-builder
  • Standard kubectl operations / blue-green deploys β†’ use senior-devops
  • General k8s security posture β†’ use cloud-security
  • "I want to run a workload" β€” that's a Deployment / Job, not an operator

Core principle: an operator is a reconcile loop, not a script

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

Operators that fail are the ones that:

  1. Treat reconcile as imperative (do this, then this, then this) instead of declarative (make actual=desired, idempotently)
  2. Don't requeue transient failures
  3. Don't use finalizers, leaving orphan resources
  4. Mutate spec instead of status
  5. Don't use the status subresource (status updates trigger spec reconciles β†’ loop)
  6. Block in reconcile (long HTTP calls, locks)
  7. Forget leader election β†’ split-brain on multi-replica deploys

The 3 tools below catch each of these.

Quick start

SKILL=engineering/kubernetes-operator/skills/kubernetes-operator

# Validate a CRD design
python "$SKILL/scripts/crd_validator.py" --crd config/crd/myapp.yaml

# Lint a Go reconcile function
python "$SKILL/scripts/reconcile_lint.py" --controller controllers/myapp_controller.go

# Score against OperatorHub Capability Levels (1-5)
python "$SKILL/scripts/operator_capability_audit.py" --operator-dir .

The 3 Python tools

All stdlib-only. Run with --help.

crd_validator.py

Validates a CRD YAML against operator-pattern best practices.

python scripts/crd_validator.py --crd config/crd/myapp.yaml
python scripts/crd_validator.py --crd config/crd/ --format json

Checks:

  • spec.versions[*].subresources.status is set (status subresource)
  • spec.scope is Namespaced (not Cluster) unless explicitly justified
  • Singular and listKind defined
  • spec.versions[*].schema.openAPIV3Schema has type definitions (no x-kubernetes-preserve-unknown-fields: true at top level)
  • A version is marked served: true AND storage: true
  • Conditions array is in the schema (allows metav1.Conditions)
  • Printer columns include Age and Status/Phase

reconcile_lint.py

Lints a Go controller reconcile function for anti-patterns.

python scripts/reconcile_lint.py --controller controllers/myapp_controller.go

Checks (regex-based heuristics):

  • Returns are (ctrl.Result, error) shape
  • Errors trigger a non-zero requeue (return ctrl.Result{Requeue: true}, err)
  • client.Update() on the spec object is flagged (controllers should update only status)
  • time.Sleep inside reconcile is flagged (use RequeueAfter)
  • HTTP calls without context cancellation are flagged
  • Missing defer after a finalizer add
  • No IsConditionTrue / SetCondition calls when conditions present in CRD
  • Reconcile function exceeds 80 lines (extract subroutines)

operator_capability_audit.py

Scores an operator against OperatorHub's 5 Capability Levels.

python scripts/operator_capability_audit.py --operator-dir .

Levels:

  • L1 β€” Basic Install: CRD defined, controller deploys it
  • L2 β€” Seamless Upgrades: PDBs, conversion webhooks, version skew strategy
  • L3 β€” Full Lifecycle: backups, restores, failure recovery
  • L4 β€” Deep Insights: metrics endpoint, Prometheus rules, alerts
  • L5 β€” Auto Pilot: auto-scaling, auto-tuning, anomaly detection

Reports current level + concrete next steps to advance one level.

Tooling landscape

Pick a framework based on language and complexity. See references/tooling_landscape.md.

| Framework | Language | Best for

FAQ

What is an operator?

It is a program that watches a Kubernetes resource and keeps the real system matching what that resource describes.

Is this for running a normal app?

No. A plain app runs as a Deployment or Job, and this skill is for building custom controllers.

What common bugs does it look for?

Missing finalizers, blocking calls, no retry on transient errors, status drift and overly broad permissions.

Details

Original description by the author

Use when building a Kubernetes operator or CRD (controller-runtime, kubebuilder, operator-sdk, KOPF), before writing the controller. Validates CRDs with crd_validator.py, lints reconcile loops with reconcile_lint.py and scores OperatorHub capability level.

repo: alirezarezvani/claude-skills

Popularity

GitHub stars
29k
Ranking position
#9564
License
MIT
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills