-
api/<version>/*_types.go— Go types for CRDs (Spec/Status) with kubebuilder markers (validation, resource, shortNames, etc.).groupversion_info.go— Registers the API Group/Version and kinds; exposesAddToScheme.doc.go— Package-level markers (e.g.,+groupName=game.example.com,+kubebuilder:object:generate=true).zz_generated.deepcopy.go— Auto-generated bycontroller-gen object; required for safe runtime copying.
-
internal/controller/<kind>_controller.go— Reconcilers for each kind (business logic). Defines watches, ownership, predicates, andReconcile.SetupWithManager(...)— Wires reconcilers into the manager; declaresFor(...),Owns(...), and options.
-
cmd/main.go- Process entrypoint. Builds a controller-runtime
Manager, adds schemes, registers reconcilers, configures metrics/health and leader election, then starts the manager.
- Process entrypoint. Builds a controller-runtime
-
config/crd/— Generated CRD YAMLs that make the API server understand custom resources.rbac/— Roles/Bindings generated from//+kubebuilder:rbacmarkers in controllers.manager/— Operator Deployment/SA/Service/metrics/health config; the runtime spec for the manager pod.default/— Kustomize overlay that stitches CRDs/RBAC/manager together (namespace, labels, patches); used bymake deploy.samples/— Example CustomResources to test the controllers.
-
Dockerfile- Multi-stage build that compiles
cmd/main.gointo a staticmanagerbinary and packages it into a minimal runtime image.
- Multi-stage build that compiles
-
Makefile- Common workflows:
make generate: runcontroller-gen object(deepcopy).make manifests: runcontroller-gen rbac,crd(RBAC & CRDs).make install: apply CRDs to the current cluster.make deploy: deploy the operator (kustomizeconfig/default).make run: run manager locally against current kubeconfig.make docker-build: build container image.
- Common workflows:
Notes
- Kubebuilder v4 layout places reconcilers under
internal/controller/(notcontrollers/) and the entrypoint atcmd/main.go(not repo root). - Generators read markers from
api/*andinternal/controller/*to produce CRDs and RBAC.