The perception that Kubebuilder is an "anti-pattern" in Go #5630
-
|
can it become more go library like in the future(by compose library), less of marker, scaffold, replace by interface etc? I'd like no constraint on project structure, say currently, it scaffold all crd types into the same package, what if I want it to place in separate package by domain logic, not by types. current scaffold way, make things hard to do(separate package by domain, pure go test), for each new kind create. in order to do such way, one may not use kubebuilder cli at all, or use in the half way ( with thin wrapper etc), is it possible that kubebuilder can have better ideas? note the following are express well by ai for my perception. post it here, to bring more thought, I see it's hard to do such change, just provide some feedbacks here. The perception that Kubebuilder is an "anti-pattern" in Go often stems from its heavy reliance on code generation and scaffolding rather than standard Go library conventions. While it is the standard tool for building Kubernetes Operators, its design choices clash with typical Go philosophy in several ways:
Go developers generally prefer small, composable libraries. Kubebuilder operates as a scaffolding tool that generates a large amount of boilerplate code.
Kubebuilder uses special comments (e.g.,
The tool abstracts away the complexities of informers, caches, and the reconciliation loop.
Kubebuilder enforces a very specific directory layout (e.g.,
Summary Table: Go Idioms vs. Kubebuilder
Would you like to explore lighter alternatives to Kubebuilder for writing controllers, such as using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Hi @chinglinwen, Thank you for taking the time to raise these points and share your perspective. First of all, we are always open to feedback, suggestions, and improvements. That said, a significant portion of the content shared here appears to be AI-generated and includes several inaccuracies and misconceptions about Kubebuilder’s purpose and design. I’ll try to clarify the main points below. 💬 On the “anti-pattern” perceptionMany of the concerns raised seem to stem from misunderstandings or disagreement with the intended purpose of the project. Kubebuilder is not trying to be a minimal Go library. It is a framework and toolkit designed to accelerate development, reduce boilerplate, and standardize patterns across Kubernetes operators. If those goals don’t align with a specific use case, alternative approaches (like using controller-runtime directly) are valid—but that does not make Kubebuilder an anti-pattern. In fact, using controller-runtime directly would typically require you to implement the same patterns and structure that Kubebuilder already provides, but without its tooling, scaffolding, and ecosystem support. 📚 Kubebuilder Book references
🧩 “Go developers prefer small, composable libraries”
This characterization is not accurate. Kubebuilder generates a base project scaffold, but the resulting project is composable by design:
The scaffold represents a common starting point that covers the majority of use cases, not a rigid or closed system. 🧠 “Opaque abstractions”
This is incorrect. Kubebuilder itself does not abstract these concepts away. It builds on top of the 🏷️ “Magic comments (markers)”Please refer to the Kubebuilder README:
🏗️ “Opinionated project structure”
Kubebuilder follows:
See also:
So while the structure may appear “opinionated**,” it is based on community standards, real-world usage, and ecosystem feedback.** Additionally:
Regards
Can you provide an example about what you are trying to say here? Happy to continue the discussion—especially if you can share concrete examples of the challenges you’re facing and based in your analysis. Thanks again for the feedback. For now, I am closing this as resolved. |
Beta Was this translation helpful? Give feedback.

Hi @chinglinwen,
Thank you for taking the time to raise these points and share your perspective.
First of all, we are always open to feedback, suggestions, and improvements. That said, a significant portion of the content shared here appears to be AI-generated and includes several inaccuracies and misconceptions about Kubebuilder’s purpose and design. I’ll try to clarify the main points below.
💬 On the “anti-pattern” perception
Many of the concerns raised seem to stem from misunderstandings or disagreement with the intended purpose of the project.
Kubebuilder is not trying to be a minimal Go library. It is a framework and toolkit designed to accelerate development, reduce boilerplate, an…