Don't Start from Scratch
Imagine you want to build a web server. You could write raw TCP socket handling from scratch, or you could use a framework like Express or Django that handles routing, middleware, and connection pooling for you. The framework doesn't limit what you can build — it eliminates the boilerplate so you can focus on your application logic.
Writing a Kubernetes controller has the same problem. Before you write a single line of business logic, you need to handle:
- Setting up a connection pool to the Kubernetes API server
- Managing an in-memory cache of cluster objects (so you don't hammer the API server with every reconcile)
- Implementing leader election (so that if you run three replicas of your controller for high availability, only one is active at a time)
- Generating CRD YAML from your Go structs
- Setting up health check endpoints and metrics
Doing all of this manually is error-prone and time-consuming. Instead, we use scaffolding tools:
Kubebuilder is the core scaffolding tool maintained by the Kubernetes Special Interest Group (SIG) API Machinery. It generates a complete, production-ready project skeleton: a Makefile, Dockerfile, main.go entrypoint, and the directory structure expected by the ecosystem. It also provides the controller-runtime library, which is the actual framework your controller runs on top of.
Operator SDK is built on top of Kubebuilder (maintained by Red Hat / now part of the CNCF). It adds extra features on top of the Kubebuilder foundation:
- Integration with the Operator Lifecycle Manager (OLM), which is a system for distributing and upgrading Operators in a cluster (similar to an app store for Operators).
- Support for writing Operators in Ansible or Helm (for simpler use cases).
- Scorecard tooling for validating Operator quality.
For Go Operators, the experience is nearly identical between the two tools — Operator SDK simply wraps Kubebuilder. In this course, we focus on the Kubebuilder pattern, as it is the industry-standard foundation that both tools share.