#2909·k0s

Improvements to Kubernetes related code generation

Author: twz123Created Mar 23, 2023Updated Sep 24, 2026
Labelschore

Is your feature request related to a problem? Please describe.

K0s uses Kubebuilder's controller-tools to generate the CRD manifests and deepcopy code, as well as the standard Kubernetes code-generator to auto-generate the typed go clients for its Custom Resource types.

The way k0s does it right now is a bit different than other projects, including Kubernetes itself do it. That makes it a bit challenging to work with k0s's CRDs, as things don't work the way they work elsewhere.

Describe the solution you would like

Use the code generation tools in a more standard way. Moreover, there are even more code generation features available in the aforementioned libraries which might have a positive impact on the k0s codebase.

Some fixes/improvements that may be worthwhile to implement:

  • Make package-level annotations work
  • Have shorter package paths
  • Have a look into the other code-generators
    • defaulter-gen might help streamlining the hand-made defaulting code in k0s
    • register-gen generates register.go files

Describe alternatives you've considered

No response

Additional context

There's also conversion-gen, which allows for evolving API versions by generating boilerplate to convert between multiple external versioned representations of a CRD and the internal unversioned representation of a CRD. Maybe that might help in sorting out the "node config vs. cluster config" difficulty.