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 underapi/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:
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.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:4) Build pipeline: generate, manifests, build
Run these Make targets to produce generated code, the CRD YAML, and the manager binary:make generate— runscontroller-gento 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.
Example invocation of
make generate in the lab environment:
5) Install the CRD
Apply the generated CRD YAML into your Kubernetes cluster with:6) Run the controller locally
Start the manager locally to verify the operator connects to the API server and the controller registers. The demos usedmake 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:
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:image: nginx and replicas: 2:
- 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.
WebApp spec), add status updates, and include appropriate RBAC rules for the created resources.