Make sure the domain, repository path, and project name you pass to
kubebuilder init match the exact values shown below: domain kodekloud.com, repo github.com/kodekloud/webapp-operator, and project name webapp-operator. These identifiers are referenced across the scaffold and in generated API group names.-
- Create the project scaffold
-
- Add the WebApp API
-
- Confirm scaffolded files
-
- Generate CRD manifests
-
- Build the manager (sanity build)
-
- Confirm project metadata
- Links and references
1) Create the project scaffold
Initialize the Kubebuilder project using the course-specific identifiers. This sets the project-wide domain, repository path, and project name that Kubebuilder uses to build your API group names and module paths.PROJECT (project config) and confirm these values remain set. Example configuration created by Kubebuilder:
domain + group to assemble the fully qualified API group (for example, webapp.kodekloud.com). If domain/repo/projectName are incorrect, generated import paths and CRD names will differ from the course expectations.
2) Add the WebApp API
Scaffold the API types and controller for theWebApp resource:
- API type definitions (Go structs for
SpecandStatus) inapi/v1/webapp_types.go. - Group/version registration in
api/v1/groupversion_info.go. - The reconciler/controller skeleton in
controllers/webapp_controller.go. - Tests and other scaffolded files (e.g.,
controllers/webapp_controller_test.go).
- The
--resourceflag creates the CRD-related type and markers. - The
--controllerflag scaffolds a reconciler skeleton to watch and reconcileWebAppresources.
3) Confirm scaffolded files
Open your project in an editor (e.g., VS Code) and confirm these generated files exist and are populated:
The generated
cmd/main.go will register your API with the manager’s scheme. Example snippet:
webappv1 types are registered and available to the manager. When importing standard Kubernetes types later (e.g., apps/v1), the code uses aliases like appsv1 to avoid naming collisions.
If
webappv1.AddToScheme(scheme) is missing from cmd/main.go, the manager won’t recognize your custom API and controller setup will fail. Do not remove the scaffolded scheme registration lines.4) Generate CRD manifests
Generate the CRD YAML using the provided Make target:- Runs
controller-gento read the marker comments in your Go types. - Emits CRD YAML and other resource manifests under
config/.
make manifests.
5) Build the manager (sanity build)
Compile the manager binary to ensure the project builds cleanly:cmd/main.go, producing bin/manager. Typical output:
- Generated types and controllers compile.
- The project’s module and imports are correct.
- The manager binary exists and is ready for further development or testing.
6) Confirm project metadata
Verify project configuration and the resource metadata added bycreate api. The project config and resource list should reflect the course identifiers and the WebApp resource.
Representative excerpt:
- domain:
kodekloud.com - repo:
github.com/kodekloud/webapp-operator - projectName:
webapp-operator - resource group:
webapp - version:
v1 - kind:
WebApp - controller:
true
Links and references
- Kubebuilder docs: https://book.kubebuilder.io/
- Controller Runtime: https://pkg.go.dev/sigs.k8s.io/controller-runtime
- controller-gen: https://github.com/kubernetes-sigs/controller-tools/tree/master/cmd/controller-gen
controllers/webapp_controller.go, add RBAC markers, and write e2e tests to validate operator behavior.