Skip to content

Latest commit

 

History

History
 
 

kubebuilder

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Kubebuilder

Authors: Ellen Körbes, Dan Miller

Enable live-update for developing Kubebuilder projects.

Usage

To use this extension, create a new directory, import the extension into your Tiltfile, and call the kubebuilder() function. E.g.

load('ext://kubebuilder', 'kubebuilder') 
kubebuilder("domain.tilt.dev", "tiltgroup", "v1", "CustomKind") 

The arguments are domain, group, version, and kind for the operator to be created.

It is required that kubebuilder be installed in the system and present on PATH. If you don't have Kubebuilder installed, check out Kubebuilder's Quick Start guide.

In Depth

This extension automates live-update setup for CRD changes, controller code changes, and sample YAML changes.

CRD Changes

Let's say I have a CustomKind CRD:

$ kubectl get CustomKind
NAME                AGE
customkind-sample   5m41s

I can change the CRD definition by adding the code below, which changes the columns printed on kubectl output:

// +kubebuilder:printcolumn:name="Foo",type=string,JSONPath=`.spec.foo`

And the output gets instantly updated:

$ kubectl get CustomKind 
NAME                FOO 
customkind-sample   bar

Sample YAML Changes

Changes to files in the ./config/samples files also get automatically updated. E.g. by changing the following in my sample YAML...

spec:
  # Add fields here
  foo: newvalue

I now get the following output:

$ kubectl get CustomKind 
NAME                FOO 
customkind-sample   newvalue

Controller Code Changes

Lastly, any changes to controller code also update automatically. For example, by adding the following to ./controllers/customkind_controller.go...

log := r.Log.WithValues("customkind", req.NamespacedName)
log.Info("CONTROLLER SAYS HELLO!")

Tilt's logs immediately update to display the following output:

[manager] 2020-11-30T14:47:31.550Z    INFO    controllers.CustomKind    CONTROLLER SAYS HELLO!    {"customkind": "default/customkind-sample"}

Clean Up

To delete all Kubebuilder resources from your cluster, use Tilt's tilt down command.