Monday, August 14, 2023

KubeBuilder

Use kubebuilder to start a new project:

 

     kubebuilder init --domain my.domain --repo my.domain/guestbook
 
This step creates make file, dockerfile etc.
 
Once a project gets created, you normally run the following command to add API
 
     kubebuilder create api --group webapp --version v1 --kind CronJob 

Then you normally would edit the files in api/v1 _types.go files to add your own struct
basically data structure for your api. and make changes to the controller.go in the
controllers directory to implement your business logic.

Then you normally would need to run:
    make manifests to generate crds, roles, role bindings etc.
 
    make generate to generate code in zz_generated.deepcopy.go to capture changes that you
make to apis, that is, changes made in _types.go file will need to be reflected in
zz_generated.deepcopy.go file.

No comments:

Post a Comment