kubernetes-operators
Designs and audits Kubernetes Operators — CRD shape, reconcile-loop correctness, finalizer and status-subresource handling, OperatorHub capability levels, framework choice. Use when building a controller for a CRD, reviewing an operator for capability gaps, or designing the API surface of a Custom Resource. Not for general pod debugging — see kubernetes-operations.
What this skill does
# Kubernetes Operators — CRD and reconcile review
For pod-level debugging (CrashLoopBackOff, ImagePullBackOff, scheduling failures) see the `kubernetes-operations` skill. For Argo-managed deployments see `argocd-operations`.
Most "operator bugs" are reconcile-loop bugs, not Kubernetes bugs: missing finalizers, blocking calls, no requeue on transient error, status drift, RBAC over-grant. The three Python scripts shipped here catch the deterministic subset before code reaches a cluster.
## When to invoke
Run the analyzers first — they're stdlib Python, fast, and surface most routine issues:
```bash
SKILL=plugins/kubernetes-skills/skills/kubernetes-operators
python3 "$SKILL/scripts/crd_validator.py" --crd config/crd/
python3 "$SKILL/scripts/reconcile_lint.py" --controller controllers/
python3 "$SKILL/scripts/operator_capability_audit.py" --operator-dir .
```
All three accept `--format json`. Triage by severity: FAIL blocks merge, WARN files an issue.
## Pre-flight: is an operator the right shape?
Operators are for *stateful, lifecycle-managed* workloads. Reach for one when:
- The thing being managed has an external API (RDS, Kafka topics, GitHub repos).
- Day-2 operations are non-trivial (backup, restore, version upgrade, failover).
- A Helm chart + bash isn't enough — you need a controller that *observes and re-acts*.
Don't reach for an operator when:
| Want | Better tool |
|---|---|
| Run a workload | `Deployment` / `StatefulSet` / `Job` |
| Package + parameterize manifests | Helm chart or Kustomize |
| Sync repo → cluster | ArgoCD / Flux |
| External-resource lifecycle, no day-2 complexity | Terraform / Crossplane composition |
## Core principle: reconcile is declarative, not imperative
The wrong shape:
```
if creating: do A
elif updating: do B
elif deleting: do C
```
The right shape:
```
desired = read(spec)
actual = observe(world)
diff = compare(desired, actual)
for change in diff: apply(change) # idempotently
update_status()
```
Reconcile must be safe to run twice in a row with no spec change → same result, zero side effects. If your function isn't idempotent, your operator will fight itself.
## CRD design — the non-negotiables
`crd_validator.py` checks these. The list is short on purpose; each item exists because skipping it produces a specific class of bug.
| Rule | Reason it matters |
|---|---|
| Status subresource enabled | Without it, `Status().Update()` re-triggers the spec watcher → infinite reconcile loop |
| `scope: Namespaced` unless cluster-scoped is justified | Cluster-scoped CRDs leak across tenants and complicate RBAC |
| `served: true` AND `storage: true` on exactly one version | Multiple `storage: true` is invalid; missing it breaks reads |
| OpenAPI v3 schema with typed properties | `x-kubernetes-preserve-unknown-fields: true` at the root defeats validation; users send garbage, controller crashes |
| `conditions` array in schema (for `metav1.Conditions`) | Standard way to communicate state; tooling and humans both read it |
| `additionalPrinterColumns` include Age + Status/Phase | `kubectl get` becomes useful without `-o yaml` |
| Singular + listKind defined | `kubectl get singular` works |
Beyond the validator: **version your CRD from day 1** (`v1alpha1` → `v1beta1` → `v1`) and plan a conversion webhook before you ship `v1`. Migrating storage versions later is painful.
## Reconcile loop — the non-negotiables
`reconcile_lint.py` checks Go reconcile functions for these. Regex-based, so false positives happen — read the source after a flag.
| Rule | Why |
|---|---|
| Return shape is `(ctrl.Result, error)` | controller-runtime contract |
| Errors return `RequeueAfter` or non-nil error | Otherwise transient failures wedge silently |
| Status updates use `Status().Update()`, not `Update()` | Updating spec bumps generation; users see "ghost" changes |
| No `time.Sleep` inside reconcile | Blocks the workqueue → other CRs stall. Use `RequeueAfter` |
| HTTP calls take a `context.Context` and respect it | Otherwise reconciles can't be cancelled on shutdown |
| Finalizer added before any external-resource create | Missing finalizer → user deletes CR → external resource orphans |
| Conditions set via `meta.SetStatusCondition` when CRD declares them | Hand-rolled condition munging drops `LastTransitionTime` |
| Reconcile function under ~80 lines | Extract `reconcileXxx` subroutines per concern |
## OperatorHub capability levels
`operator_capability_audit.py` scores against the OperatorHub 5-level rubric. Use it as a *progression plan*, not a checklist for one PR.
| Level | What it means | Realistic milestone |
|---|---|---|
| L1 Basic Install | CRD defined, controller deploys it | Same PR as the first reconcile |
| L2 Seamless Upgrades | PDB, conversion webhook, version skew strategy | Before first external user |
| L3 Full Lifecycle | Backup, restore, failure recovery | Before public release |
| L4 Deep Insights | `/metrics` endpoint, Prometheus rules, alerts | After L3 in production for ~1 quarter |
| L5 Auto Pilot | Auto-scaling, auto-tuning, anomaly detection | Mature operators only |
Aim for **L3 before public release**. L4/L5 are nice-to-have unless the operator manages something high-stakes.
## Framework choice
| Framework | Language | When to pick |
|---|---|---|
| **kubebuilder** | Go | Default for Go shops. Most opinionated scaffolding, aligned with SIGs |
| **controller-runtime** | Go | When kubebuilder's scaffolding is in the way (large existing codebase) |
| **operator-sdk** | Go / Helm / Ansible | Targeting OpenShift, or mixed-paradigm teams |
| **KOPF** | Python | Python shops; great for prototypes and async-heavy operators |
| **metacontroller** | Any (webhook) | Polyglot team that cannot pick a single language |
| **java-operator-sdk** | Java | JVM-only shops |
Rule of thumb: **Go shop → kubebuilder. Python shop → KOPF.** Build a one-week proof-of-concept before committing the design.
## Workflows
### Bootstrap a new operator (Go + kubebuilder)
1. Pick Group/Version/Kind: `apps.example.com/v1alpha1`, `kind=MyApp`.
2. `kubebuilder init --domain example.com --repo github.com/org/myapp-operator`.
3. `kubebuilder create api --group apps --version v1alpha1 --kind MyApp`.
4. Run `crd_validator.py` on the generated CRD. **Fix every FAIL before writing controller code.**
5. Implement reconcile — start with the simplest correct version (no finalizers, no conditions). Add complexity only when a test fails without it.
6. Run `reconcile_lint.py` on the controller.
7. Run `operator_capability_audit.py --operator-dir .` — confirm L1.
8. Test in a `kind` cluster: `kubectl apply -f config/samples/`.
9. Add status conditions + finalizers; aim for L2 in the same PR.
### Audit an existing operator
1. Run all three scripts.
2. Triage: FAIL → block release; WARN → file an issue.
3. Record current capability level in the README.
4. Plan one level advancement per quarter.
## Proactive triggers
- **CRD without status subresource** → infinite-loop bug waiting to happen. Add `subresources: {status: {}}`.
- **`time.Sleep` inside `Reconcile`** → replace with `return ctrl.Result{RequeueAfter: X}, nil`.
- **Multi-replica operator without leader election** → split-brain. Enable leader election or scale to 1.
- **Reconcile mutates `obj.Spec`** → controller is fighting users. Move to status or admission webhook.
- **No finalizer + external resource (cloud API, DB)** → orphaned resources on CR deletion. Add finalizer.
- **`x-kubernetes-preserve-unknown-fields: true` at schema root** → defeats validation. Type the schema.
## Asset templates
- `assets/crd_template.yaml` — CRD with status subresource, conditions, printer columns
- `assets/reconcile_skeleton.go` — Go reconcile function with idempotency, finalizer, condition patterns
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.