Skip to main content
Where do you actually start when building a Kubernetes operator? Handwriting the Go module, Makefile, directory tree, and all the wiring that connects your controller to the Kubernetes API can be hours of boilerplate before a single line of real logic. Kubebuilder solves that problem by scaffolding a complete operator project so you can skip straight to the interesting parts. In this guide you’ll initialize a new Kubebuilder project and verify the generated skeleton builds. By the end you will have:
  • A buildable Go module
  • A working Makefile
  • The controller-runtime manager entry point
This is a practical first step toward creating APIs, controllers, and webhooks with Kubebuilder.

Prerequisites

  • Go installed and available on your PATH. If go version fails, install Go from the official Go installation page: https://go.dev/doc/install
Check Go:

Install Kubebuilder

Kubebuilder is not installed by default. Follow the Kubebuilder quick-start installation instructions: Example install (fetches the latest binary compatible with your OS):
Make sure kubebuilder is executable and located in a directory that is on your PATH (for example /usr/local/bin).
Kubebuilder will not scaffold into a directory that already contains files. Always run kubebuilder init from an empty project folder (check your editor or run ls -la first). If the folder contains files, create a clean directory before continuing.

Verify toolchain

Confirm both Kubebuilder and Go are installed and reporting compatible versions. If versions differ significantly, the project layout and generated imports may vary.

Initialize the project

kubebuilder init scaffolds a new operator project. The most important flags: Pick these values carefully: domain and repo are embedded into package import paths and generated manifests. Example init command:
Typical scaffold output:

What Kubebuilder creates

After kubebuilder init completes, you’ll see a small project layout with source, build, and configuration files. Key files and directories: A sample PROJECT file:

Build the scaffold

The scaffold is intended to compile immediately. If make build succeeds, your Go toolchain and module path are configured correctly. Scaffold and build:
If the build completes successfully, the manager binary compiles and you’re ready to scaffold APIs, controllers, and webhooks.

Next steps

Now that the skeleton is in place and the manager compiles, continue with:
  • A tour of the directories and files Kubebuilder init created (cmd/, config/, api/, controllers/)
  • Using kubebuilder create api to define your first CustomResource and controller
  • Implementing reconcile logic in the generated controller
References and further reading:

Watch Video