Choosing the Right Scaffold for MySQL Operator: Kubebuilder vs Operator SDK
This article compares popular Kubernetes Operator scaffolding tools, explains why Kubebuilder 3.0 was selected for the radondb‑mysql‑kubernetes project, and provides step‑by‑step commands to initialize the operator and generate its API and controller code.
This is the second part of the MySQL Operator design series; the first introduced the overall architecture and design ideas. This part focuses on selecting an operator scaffolding tool and creating the project.
Operator Scaffolding Selection
Just as a construction site needs a scaffold for safe and fast building, an Operator project needs a scaffold to accelerate development and iteration. The Kubernetes community offers several mature scaffolding tools.
Operator Framework SDK : https://operatorframework.io/
Kubebuilder : https://book.kubebuilder.io/
KUDO (Kubernetes Universal Declarative Operator) : https://kudo.dev/
Charmed Operator Framework : https://juju.is/
The most active and widely used tools are Operator SDK and Kubebuilder . Both rely on the official controller‑tools and controller‑runtime, share a similar project layout, and differ in features.
Kubebuilder
Includes the envtest package for isolated etcd and apiserver testing.
Automatically generates a Makefile to build, test, run, and generate code.
Uses kustomize to build deployment manifests.
Improved support for admission and CRD conversion WebHooks.
Operator SDK
Better support for higher‑level operators such as Ansible and Helm.
Integrates with Operator Lifecycle Manager (OLM) for upgrades and management.
Provides a scorecard sub‑command to verify best‑practice compliance.
Includes an e2e testing framework for real‑cluster tests.
Because the two ecosystems are converging and Operator SDK is moving toward Kubebuilder, we chose the more native Kubebuilder (currently at version 3.0) as the scaffolding for this project.
Creating the Project
Initialize Operator and Controller API
Kubebuilder offers quick tutorials and scaffolding for generating code related to CRDs and controller APIs. The architecture is illustrated below:
Creation Steps
Follow these two steps to create the project:
Initialize the Operator project Run the following command (domain set to radondb.com ) to generate the Makefile, image build script, configuration files, and main.go : kubebuilder init --domain=radondb.com Create the Controller Specify the API group, version, and kind as mysql , v1alpha1 , and MysqlCluster respectively, and enable both the resource and controller scaffolding:
kubebuilder create api --group mysql --version v1alpha1 --kind MysqlCluster --resource=true --controller=trueAfter executing the second command, the project gains api, crd, and controllers directories.
Design Goals
The following shows the current directory structure and function overview of the radondb-mysql-kubernetes project.
Summary
The Operator builds on Kubernetes resources and controller concepts while embedding application‑specific domain knowledge. Designing a robust Operator hinges on well‑crafted Custom Resource Definitions (CRDs). The next article will analyze the CRD design of the radondb‑mysql‑kubernetes project.
Qingyun Technology Community
Official account of the Qingyun Technology Community, focusing on tech innovation, supporting developers, and sharing knowledge. Born to Learn and Share!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
