kubebuilder init --domain example.com --repo github.com/abstractmachines/kubebuilder-tutorial
Or
kubebuilder init --domain example.com --repo github.com/abstractmachines/kubebuilder-tutorial --skip-go-version-check
Result: codegen scaffolded project
kubebuilder create api --group webapp --version v1 --kind Guestbook --resource --controller
Result: codegen
api/v1/guestbook_types.go
controllers/guestbook_controller.go
make install
Results:
- This generates yaml, including our CRD's definition/manifest. Note
kind: CustomResourceDefinition
, withgroup: webapp.example.com
, andname
ofguestbook
(lowercase version of the name'skind: Guestbook
). controller-gen
codegen; kustomize build generates./config/crd
yaml layers and then imperativelyapply
's CRD to cluster;- Hence, result:
customresourcedefinition.apiextensions.k8s.io/guestbooks.webapp.example.com created
.
make run
This will go run main.go
and controller runtime
In new tab:
k apply -f config/samples/
Result: This actually applies our custom resource
kind: Guestbook
into cluster.
k get guestbook // shows cr guestbook and time of creation
k get crds // guestbooks.webapp.example.com
k get guestbook -owide -oyaml // our sample yaml def
You can use Docker or other methods such as creating a deployment.
Let's use Docker for now:
make docker-build docker-push IMG=<some-registry>/<project-name>:tag
make deploy IMG=<some-registry>/<project-name>:tag
Result: This will create a
Deployment
and other Kustomize layers, service etc...
make uninstall // uninstall CRDs // no more `k get guestbook`
make undeploy // undeploy controller
// Shut down `make run` process in terminal