How to create new resources
This guide describes how to add a new Kubernetes custom resource (CRD) to Chantico using Kubebuilder.
Prerequisites
- Install
kubebuilder:
- Make sure your local environment is set up: How to set up the local development environment
Create the API and controller scaffolding
- Generate the resource scaffolding:
- Remove the generated integration tests (these are not used in this repo):
Define the schema
- Update the Go types in
api/v1alpha1/<resource>_types.go:
- Add the
Specfields for the desired state. - Add the
Statusfields for observed state. - Add validation markers if needed.
- Regenerate code and manifests:
Implement controller behavior
- Update the controller in
internal/controller/<resource>_controller.go:
- Implement reconcile logic.
- Add required RBAC markers for the CRD.
- Add or adjust tests in
internal/<resource>/as needed.
Apply to a cluster (optional)
If you want to test against a running dev cluster:
This installs the CRDs into the current kube-context.