In KubeVela CLI (>= v1.1.0),
vela def command group provides a series of convenient definition writing tools. With these commands, users only need to write CUE files to generate and edit definitions, instead of composing Kubernetes YAML object with mixed CUE string.
vela def init is a command that helps users bootstrap new definitions. To create an empty trait definition, run
vela def init my-trait -t trait --desc "My trait description."
Or you can use
vela def init my-comp --interactive to initiate definitions interactively.
In addition, users can create definitions from existing YAML files. For example, if a user want to create a ComponentDefinition which is designed to generate a deployment, and this deployment has already been created elsewhere, he/she can use the
--template-yaml flag to complete the transformation. The YAML file is as below
vela def init my-comp -t component --desc "My component." --template-yaml ./my-deployment.yaml to get the CUE-format ComponentDefinition
Then the user can make further modifications based on the definition file above, like removing \<change me> in workload.definition。
After initializing definition files, run
vela def vet my-comp.cue to validate if there are any syntax error in the definition file. It can be used to detect some simple errors such as missing brackets.
After confirming the definition file has correct syntax. users can run
vela def apply my-comp.cue --namespace my-namespace to apply this definition in the
my-namespace namespace。If you want to check the transformed Kubernetes YAML file,
vela def apply my-comp.cue --dry-run or
vela def render my-comp.cue -o my-comp.yaml can achieve that.
While you can use native kubectl tools to confirm the results of the apply command, as mentioned above, the YAML object mixed with raw CUE template string is complex. Using
vela def get will automatically convert the YAML object into the CUE-format definition.
Or you can list all defintions installed through
vela def list
vela def edit to edit definitions in pure CUE-format. The transformation between CUE-format definition and YAML object is done by the command. Besides, you can specify the
EDITOR environment variable to use your favourate editor.
vela def del can be utilized to delete existing definitions.