- Initialize the project with the exact course identifiers,
- Generate CRD manifests from your API types,
- Build the manager binary to verify the scaffold compiles.
- Initialize the Kubebuilder project scaffold
Make sure the
--domain, --repo, and --project-name values exactly match the course. If these are incorrect, the fully qualified group names and import paths will differ and later steps will fail.- Add the WebApp API
--resource to generate API types and --controller to scaffold a reconciler:
--resourcegenerates the Go types for the custom resource (CR).--controllerscaffolds the reconciler (controller) skeleton that watches and reconciles WebApp objects.
- Inspect scheme registration in cmd/main.go
cmd/main.go and ensure your API package registers with the manager’s scheme. This registration lets controller-runtime encode/decode webapp.kodekloud.com/v1 objects.
A typical snippet looks like:
webappv1.AddToScheme(scheme) is missing, the manager will not recognize your CRD types at runtime.
- Generate CRD manifests
controller-gen and produces artifacts under config/:
config/crd/bases and follows the naming pattern group_domain_plural.yaml, for example:
webapp.kodekloud.com_webapps.yaml
If the CRD file is missing or out of date, you most likely edited the Go type definitions without rerunning
make manifests. Always regenerate manifests after changing API types.- Sanity build the manager binary
bin/manager. You can also run the equivalent steps manually:
api/ or controllers/.
- Confirm project metadata (PROJECT file)
PROJECT file at the repository root. Verify the domain, repo, project name, and resources entry. A representative PROJECT YAML:
resources entry lists group: webapp, version: v1, kind: WebApp, and the correct domain and path. Mismatches here lead to incorrect scaffold behavior and import path errors.
- Summary & next steps
kubebuilder initsets up the project with the correct domain/repo/project name.kubebuilder create apiadds the API types and controller scaffold.make manifestsgenerates CRD YAML from API markers.make buildcompiles the manager binary to confirm the scaffold is valid.
controllers/webapp_controller.go, update your API types in api/v1/webapp_types.go, and keep regenerating manifests whenever you modify the API.
Links and references
- Kubebuilder: https://book.kubebuilder.io/
- controller-runtime: https://pkg.go.dev/sigs.k8s.io/controller-runtime
- controller-gen: https://pkg.go.dev/sigs.k8s.io/controller-tools/cmd/controller-gen
- Go tooling: https://golang.org/doc/ and
go build,go vet,go fmtdocumentation