- Prerequisites
- Installing the operator-sdk CLI (Linux / macOS)
- Initializing a new Go operator project
- Creating the WebApp API and controller
- Inspecting generated code and manifests
- Comparing the generated PROJECT layout and plugins
Prerequisites
- Go toolchain installed and configured (Go 1.19+ recommended)
- Git and curl available
- Optional: a disposable workspace (example: an ephemeral container or temporary directory)
Install operator-sdk
Linux installation (recommended steps)
Download the release binary for your architecture, verify the signed checksums, and place the binary on your PATH asoperator-sdk.
macOS (Homebrew)
You can also install via Homebrew on macOS:If you are already familiar with the Kubebuilder scaffold, the operator-sdk Go scaffold will feel familiar: you still write API types and a reconciler, and you still run a controller manager. operator-sdk layers additional tooling and plugins (manifests, scorecard, OLM) around that shared foundation.
Initialize a clean Go operator-sdk project
Start from an empty directory (for disposable workspaces you may runrm -rf *).
- controller-runtime and Go module setup (the same controller-runtime library Kubebuilder uses).
- Code generation steps (e.g.,
make generate,go generate) andgo mod tidy.
Create the WebApp API and controller
Scaffold the API groupwebapp, version v1, and kind WebApp. Use --resource to scaffold the CRD types and --controller to add a reconciler skeleton.
api/v1/webapp_types.gointernal/controller/webapp_controller.gointernal/controller/webapp_controller_test.go
go mod tidy and the codegen tasks to produce boilerplate.
Inspect the generated code
API types are located underapi/v1. The reconciler skeleton is under internal/controller (in some layouts it may appear under controllers). This separation mirrors the conceptual boundaries used by Kubebuilder.
A corrected sample of the generated list type (ensure your generated WebAppList resembles this):
Generate manifests
After you implement API fields and reconciliation logic, generate the manifests (CRDs, RBAC, webhook manifests if applicable):Comparing the PROJECT layout
ThePROJECT file is the most useful artifact when comparing scaffolds. It records the project layout and plugins the scaffold used. operator-sdk, when configured with the Kubebuilder Go layout, will include entries reflecting the Go layout plus operator-sdk plugins (manifests, scorecard, OLM).
Representative PROJECT fragment:
Files you typically see after scaffold: