Skip to main content
In this lesson you’ll install the CustomResourceDefinition (CRD) into your cluster and run the operator locally using the initial Kubebuilder-generated reconcile stub. The focus is on wiring the build pipeline, registering the CRD with the API server, and confirming that the manager starts cleanly and that the controller is registered. The reconciler still returns an empty result in this lab, so no child resources are created yet — later you can extend it to create a Deployment, Service, and ConfigMap. Work from the WebApp operator project root directory. Every Make target reads the local Makefile and project files, so running commands from elsewhere may fail.
Always run the commands from the operator project root so make targets, generated code, and file paths resolve correctly.

1) Verify the API types

Open the WebApp types file (usually under api/v1 or similar) and confirm spec and status fields are present. The starter project includes Image and Replicas on WebAppSpec. Confirm these fields and their kubebuilder markers are present:
Also ensure your file contains the resource markers for the API root, object, and the status subresource when applicable. These markers drive CRD generation.

2) Controller reconcile stub

This lab keeps the Kubebuilder-generated reconcile stub. It returns an empty result and no error, so the controller registers and the manager starts, but no child resources are created yet.
The controller being registered with the manager is sufficient for compilation and for the manager to start a worker for the WebApp kind.

3) Boilerplate and package imports

Ensure your controller package includes the standard license header, package declaration, and necessary imports (context, runtime, Kubernetes client packages etc.). For example:
If you modify imports or types, re-run generation to update deepcopy and other generated files.

4) Build pipeline: generate, manifests, build

Run these Make targets to produce generated code, the CRD YAML, and the manager binary:
  • make generate — runs controller-gen to regenerate deepcopy, conversions, and other generated code to reflect your types and kubebuilder markers.
  • make manifests — renders the CRD YAML and RBAC manifests from your Go markers.
  • make build — compiles the manager binary.
Summary of common build commands: Example invocation of make generate in the lab environment:

5) Install the CRD

Apply the generated CRD YAML into your Kubernetes cluster with:
Then verify the CRD exists:
A successful response confirms the CRD was applied and registered in the API server.

6) Run the controller locally

Start the manager locally to verify the operator connects to the API server and the controller registers. The demos used make run, but running the main package directly allows customizing probe and metrics ports. The example below disables the metrics endpoint and moves the health probe to port :8082:
Expected startup log snippets:
The “Starting workers” line indicates the manager successfully registered the controller and started its worker(s).

7) Apply sample namespace and CR

Create the demo namespace and apply the sample WebApp CustomResource. Because the reconciler is currently a no-op, the CR will be accepted by the API server but will not trigger creation of child resources. Apply the namespace and sample resource:
Verify the CR’s spec fields using JSONPath. The sample resource sets image: nginx and replicas: 2:
These checks confirm:
  • the CRD is installed,
  • the API server accepted and stored the CustomResource,
  • and your operator is running and watching the API server.

8) Summary

After completing this lab you have the operator scaffolding wired up and validated:
  • Types and generated code are present and up-to-date.
  • CRD YAML was generated and registered in the API server.
  • Manager started locally and exposes probes as configured.
  • Controller is registered and worker(s) started.
  • A sample WebApp CustomResource was accepted and can be queried.
Next steps: implement the reconcile function to perform desired actions (e.g., create a Deployment, Service, and ConfigMap based on the WebApp spec), add status updates, and include appropriate RBAC rules for the created resources.

Watch Video