Skip to content

Latest commit

 

History

History
37 lines (30 loc) · 2.24 KB

File metadata and controls

37 lines (30 loc) · 2.24 KB

Top-level anatomy (what the scaffold provides)

  • 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; exposes AddToScheme.
    • doc.go — Package-level markers (e.g., +groupName=game.example.com, +kubebuilder:object:generate=true).
    • zz_generated.deepcopy.go — Auto-generated by controller-gen object; required for safe runtime copying.
  • internal/controller/

    • <kind>_controller.go — Reconcilers for each kind (business logic). Defines watches, ownership, predicates, and Reconcile.
    • SetupWithManager(...) — Wires reconcilers into the manager; declares For(...), 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.
  • config/

    • crd/ — Generated CRD YAMLs that make the API server understand custom resources.
    • rbac/ — Roles/Bindings generated from //+kubebuilder:rbac markers 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 by make deploy.
    • samples/ — Example CustomResources to test the controllers.
  • Dockerfile

    • Multi-stage build that compiles cmd/main.go into a static manager binary and packages it into a minimal runtime image.
  • Makefile

    • Common workflows:
      • make generate : run controller-gen object (deepcopy).
      • make manifests : run controller-gen rbac,crd (RBAC & CRDs).
      • make install : apply CRDs to the current cluster.
      • make deploy : deploy the operator (kustomize config/default).
      • make run : run manager locally against current kubeconfig.
      • make docker-build : build container image.

Notes

  • Kubebuilder v4 layout places reconcilers under internal/controller/ (not controllers/) and the entrypoint at cmd/main.go (not repo root).
  • Generators read markers from api/* and internal/controller/* to produce CRDs and RBAC.