How to generate code using the code generator for the custom resource definition

1.5k views Asked by At

I want to use serving api which is the part of the knative serving repo to create serving application. Since i'm writing a custom controller, i need to make use of Go client. I'm finding it difficult to generate boiler plate code using the code-generator. I'm following the below mentioned blog on how to do it.

  1. https://insujang.github.io/2020-02-13/programming-kubernetes-crd/#write-template-code
  2. https://blog.openshift.com/kubernetes-deep-dive-code-generation-customresources/

But i couldn't achieve it. Any help is appreciated.

1

There are 1 answers

6
Jonas On BEST ANSWER

Yes, code generation for controllers is not the most easy thing. And it has changed over the years.

To start writing a controller with code generation, I would recommend to use Kubebuilder and follow the Kubebuilder guide. And perhaps do custom things when that is understood.

The Kubebuilder guide includes chapters on how to generate CRD code using controller-gen.