How-to

    In this section we will introduce how to define a trait.

    A trait in KubeVela can be defined by simply reference a existing Kubernetes API resource.

    Note that in this case, all fields in the referenced resource’s spec will be exposed to end user and no metadata (e.g. etc) are allowed to be set trait properties. Hence this approach is normally used when you want to bring your own CRD and controller as a trait, and it dose not rely on annotations etc as tuning knobs.

    Using CUE as Trait Schematic

    The recommended approach is defining a CUE based schematic for trait as well. In this case, it comes with abstraction and you have full flexibility to templating any resources and fields as you want. Note that KubeVela requires all traits MUST be defined in section (not output) in CUE template with format as below:

    Let’s attach this trait to a component instance in Application:

    CUE based trait definitions can also enable many other advanced scenarios such as patching and data passing. They will be explained in detail in the following documentations.