Skip to main content
You previously built a web app operator using Kubebuilder. In this lesson you’ll scaffold the same Go operator with the Operator SDK and compare the resulting project layout. The objective is to observe the initial scaffold and reconcile model—this is not a walkthrough to re-implement the web app logic. This guide covers:
  • 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

Download the release binary for your architecture, verify the signed checksums, and place the binary on your PATH as operator-sdk.
Import and verify the release signing key, then verify the checksums:
Make the binary executable and move it into a location on your PATH:

macOS (Homebrew)

You can also install via Homebrew on macOS:
Verify the CLI is available and inspect the binary metadata:
Note: the reported “kubernetes version” refers to the Kubernetes client libraries bundled with the SDK binary, not your cluster version.
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 run rm -rf *).
What to watch for as the project initializes:
  • controller-runtime and Go module setup (the same controller-runtime library Kubebuilder uses).
  • Code generation steps (e.g., make generate, go generate) and go mod tidy.
This confirms the operator runtime foundation (manager, client, event watching, reconcile loop) is shared between Kubebuilder and operator-sdk.

Create the WebApp API and controller

Scaffold the API group webapp, version v1, and kind WebApp. Use --resource to scaffold the CRD types and --controller to add a reconciler skeleton.
Typical generated artifacts:
  • api/v1/webapp_types.go
  • internal/controller/webapp_controller.go
  • internal/controller/webapp_controller_test.go
The SDK also runs go mod tidy and the codegen tasks to produce boilerplate.

Inspect the generated code

API types are located under api/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):
This produces the CRD YAML, RBAC roles, and other required manifests for deploying your operator.

Comparing the PROJECT layout

The PROJECT 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:
Quick comparison table: Kubebuilder vs operator-sdk scaffolds Files you typically see after scaffold:

Key takeaway

The operator-sdk Go plugin uses the same controller-runtime and Kubebuilder-style project layout. The primary differences are the tooling additions and plugins operator-sdk provides for packaging, validation, and distribution (OLM/scorecard). If you understand the Kubebuilder workflow, the operator-sdk Go scaffold will be immediately recognizable and comfortable to work with.

Watch Video