| name | k8s-workflow |
| description | Guide Kubernetes operator development with Kubebuilder, kind, Tilt, and Kustomize. Use when Codex needs to scaffold or iterate on CRDs, controllers, or webhooks; stand up a safe local kind cluster; run a fast operator dev loop; or verify CRDs, pods, and webhook state. |
Kubernetes Operator Workflow
Operate in a dev-only posture. Refuse mutating cluster operations unless the current kubectl context starts with kind-, unless the user explicitly overrides and accepts the risk.
Quick Start
- Run
scripts/prereqs.sh from the target repo root to check or install kind, kubectl, kustomize, tilt, go, and kubebuilder.
- Run
scripts/setup-kind.sh [cluster-name] to create and select a local kind cluster.
- Run
scripts/deploy-dev.sh [config/dev] to apply the dev overlay.
- Run
scripts/verify-dev.sh [namespace] to inspect CRDs, pods, webhooks, and recent events.
- Use
references/command-mapping.md when translating the original Claude plugin commands into Codex actions.
Required Discovery
Ask these before writing code:
- CRD purpose
- Spec fields with types and requiredness
- Status fields
- Webhook type: validating, mutating, or both
- Defaulting rules
- Validation invariants
- RBAC scope: namespaced or cluster-scoped
- Managed child resources
- Webhook failure policy
- Safety gates such as annotations or labels
Build Workflow
- Scaffold with Kubebuilder:
kubebuilder init --domain <domain> --repo <module>
kubebuilder create api --group <group> --version v1 --kind <Kind>
kubebuilder create webhook --group <group> --version v1 --kind <Kind> --defaulting --programmatic-validation
- Implement CRD types in
api/v1/*_types.go.
- Run
make generate && make manifests.
- Implement reconcile logic in
internal/controller/*_controller.go.
- Implement defaulting and validation in
api/v1/*_webhook.go.
- Add the local dev loop with
$k8s-templates.
- Prefer
tilt up or make dev for normal iteration.
Manual Fallback Cases
Do a manual build, image load, and apply cycle when:
- CRD schema changed
- Dockerfile or base image changed
- Go dependencies changed in a way that affects the container image
- Tilt is not recovering correctly
Validation
- Verify CRDs are installed.
- Verify manager and webhook pods are healthy.
- Submit a valid sample CR and confirm reconcile activity.
- Submit an invalid CR and confirm webhook rejection.
- Update the target repo
README.md with a short runbook covering dev, logs, and sample CR usage.
Safety Notes
scripts/context-guard.sh is the portable version of the plugin preflight guard. Use it as a reference or wrapper before mutating kubectl, helm, or kustomize commands.
- Codex skills do not provide automatic hooks, so apply these guardrails explicitly.