Friday, August 18, 2023

To git restore all the unstaged files

 Sometimes, you may purposely delete some of the files for testing, then you will need to restore these files, it will take a lot of key strokes if you do file by file, the below command can restore all the unstaged files in git


git restore -- $(git ls-files -m)

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.