Definition Protocol
KubeVela is fully programmable via CUE, while it leverage Kubernetes as control plane and align with the API in yaml.
You can manage the definition in CUE and the vela def
command will render it into Kubernetes API with the following protocol.
#
ComponentDefinitionThe design goal of ComponentDefinition is to allow platform administrators to encapsulate any type of deployable products into "components" to be delivered. Once defined, this type of component can be referenced, instantiated and delivered by users in the Application
.
Common component types include Helm Chart, Kustomize directory, a set of Kubernetes YAML files, container images, cloud resource IaC files, or CUE configuration file modules, etc. The component supplier corresponds to the real-world role, which is generally a third-party software distributor (ISV), a DevOps team engineer, or a code package and image generated by the CI system you built.
ComponentDefinition can be shared and reused. For example, a Helm chart, a CUE module, or a Terraform module. Another example is, for an Alibaba Cloud RDS
component type, end users can select the same Alibaba Cloud RDS
component type in different applications and instantiate them into cloud database instances with different specifications and different parameter configurations.
Let's take a look at the frame format of ComponentDefinition:
Here is a complete example to introduce how to use ComponentDefinition.
#
TraitDefinitionTraitDefinition provides a series of DevOps actions for the component that can be bound on demand. These operation and maintenance actions are usually provided by the platform administrator, such as adding a load balancing strategy, routing strategy, or performing scaler, gray release strategy, etc.
The format and field functions of the TraitDefinition are as follows:
Let's look at a practical example:
#
PolicyDefinitionPolicyDefinition is simimarly to TraitDefinition, the difference is that TraitDefinition acts on a single component but PolicyDefinition is to act on the entire application as a whole (multiple components).
It can provide global policy for applications, commonly including global security policies (such as RBAC permissions, auditing, and key management), application insights (such as application SLO management, etc.).
The format is as follows:
A specific example is shown below:
#
WorkflowStepDefinitionWorkflowStepDefinition is used to describe a series of steps that can be declared in the workflow, such as the deployment of execution resources, status check, data output, dependent input, external script call, etc.
An actual WorkflowStepDefinition is as follows:
#
The Standard Protocol Behind AbstractionOnce the application is created, KubeVela will tag the created resources with a series of tags, which include the version, name, type, etc. of the application. Through these standard protocols, application components, traits and policies can be coordinated. The specific metadata list is as follows:
Label | Description |
---|---|
workload.oam.dev/type | Corresponds to the name of ComponentDefinition |
trait.oam.dev/type | Corresponds to the name of TraitDefinition |
app.oam.dev/name | Application name |
app.oam.dev/component | Component name |
trait.oam.dev/resource | outputs.\<resource type\> in Trait |
app.oam.dev/appRevision | Application Revision Name |
#
Definition Runtime ContextIn the Definition, some runtime context information can be obtained through the context
variable. The specific list is as follows, where the scope indicates which module definitions the Context variable can be used in:
Context Variable | Description | Scope |
---|---|---|
context.appRevision | The app version name corresponding to the current instance of the application | ComponentDefinition, TraitDefinition |
context.appRevisionNum | The app version number corresponding to the current instance of the application. | ComponentDefinition, TraitDefinition |
context.appName | The app name corresponding to the current instance of the application. | ComponentDefinition, TraitDefinition |
context.name | component name in ComponentDefinition and TraitDefinition,policy in PolicyDefinition | ComponentDefinition, TraitDefinition, PolicyDefinition |
context.namespace | The namespace of the current instance of the application | ComponentDefinition, TraitDefinition |
context.revision | The version name of the current component instance | ComponentDefinition, TraitDefinition |
context.parameter | The parameters of the current component instance, it can be obtained in the trait | TraitDefinition |
context.output | Object structure after instantiation of current component | ComponentDefinition, TraitDefinition |
context.outputs.<resourceName> | Structure after instantiation of current component and trait | ComponentDefinition, TraitDefinition |
At the same time, in the Workflow system, because the context
has to act on the application level, it is very different from the above usage. We introduce it separately:
Context Variable | Description | Scope |
---|---|---|
context.name | The name of the current instance of the application | WorkflowStepDefinition |
context.namespace | The namespace of the current instance of the application | WorkflowStepDefinition |
context.labels | The labels of the current instance of the application | WorkflowStepDefinition |
context.annotations | The annotations of the current instance of the application | WorkflowStepDefinition |
Please note that all the Definition concepts introduced in this section only need to be understood by the platform administrator when they want to expand the functions of KubeVela. The end users will learn the schema of above definitions with visualized forms (or the JSON schema of parameters if they prefer) and reference them in application deployment plan. Please check the Generate Forms from Definitions section about how this is achieved.