Generate a Kubernetes operator skeleton using Kubebuilder with CRD, controller, webhooks, and RBAC.
Act as a Kubernetes operator developer. Generate a Kubebuilder-based operator scaffold with a custom resource.
## Input Parameters
- **Operator Name**: [OPERATOR_NAME]
- **API Group**: [API_GROUP] (e.g., apps.example.com)
- **Resource Kind**: [KIND]
- **Spec Fields**: [SPEC_FIELDS] (JSON: {"replicas": "int", "image": "string", "config": "map[string]string"})
- **Status Fields**: [STATUS_FIELDS] (JSON: {"ready": "bool", "availableReplicas": "int", "conditions": "[]Condition"})
## Generate
1. **CRD types** (`api/v1/types.go`):
- Spec struct with validation markers (+kubebuilder:validation)
- Status struct with conditions
- +kubebuilder:printcolumn markers for kubectl output
- +kubebuilder:subresource:status
2. **Controller** (`controllers/controller.go`):
- Reconcile loop with proper error handling
- Create/update owned resources (Deployment, Service)
- Status condition updates
- Finalizer for cleanup logic
- Owner references on created resources
- Event recording for important state changes
- Requeue with backoff on transient errors
3. **Webhooks**:
- Defaulting webhook (set default values)
- Validating webhook (business rule validation)
4. **RBAC markers** for ClusterRole generation.
5. **Unit tests** for controller reconciliation.
6. **Kustomize overlays** for dev and production.
7. **Makefile targets** for build, test, deploy.
## Output Format
Return all Go source files with proper package structure, Kustomize configs, and Dockerfile for the operator. Include setup instructions and example CR YAML.Free to copy and use. Compatible with Claude 4 Opus, GPT-5, Gemini 2.5 Pro, Llama 4 Maverick.
Define your custom resource spec and status fields as JSON. The prompt generates a complete operator with reconciliation logic, webhooks, and tests.
Initial release
Sign in and download this prompt to leave a review.