Designing Workflow Steps
#
OverviewWorkflow
allows you to customize steps in Application
, glue together additional delivery processes and specify arbitrary delivery environments. In short, Workflow
provides customized control flow and flexibility based on the original delivery model of Kubernetes(Apply). For example, Workflow
can be used to implement complex operations such as pause, manual approval, waiting status, data flow, multi-environment gray release, A/B testing, etc.
Workflow
is a further exploration and best practice based on OAM model in KubeVela, it obeys the modular concept and reusable characteristics of OAM. Each workflow module is a "super glue" that can combine your arbitrary tools and processes. In modern complex cloud native application delivery environment, you can completely describe all delivery processes through a declarative configuration, ensuring the stability and convenience of the delivery process.
#
Using workflowWorkflow
consists of steps, you can either use KubeVela's [built-in workflow steps], or write their own WorkflowStepDefinition
to complete the operation.
We can use vela def
to define workflow steps by writing Cue templates
. Let's write an Application
that apply a Tomcat using Helm chart and automatically send message to Slack when the Tomcat is running.
#
Workflow StepsKubeVela provides several CUE actions for writing workflow steps. These actions are provided by the vela/op
package. In order to achieve the above scenario, we need to use the following three CUE actions:
Action | Description | Parameter |
---|---|---|
ApplyApplication | Apply all the resources in Application. | - |
Read | Read resources in Kubernetes cluster. | value: the resource metadata to be get. And after successful execution, value will be updated with resource definition in cluster.err: if an error occurs, the err will contain the error message. |
ConditionalWait | The workflow step will be blocked until the condition is met. | continue: The workflow step will be blocked until the value becomes true . |
For all the workflow actions, please refer to Cue Actions
After this, we need two WorkflowStepDefinitions
to complete the Application:
- Apply Tomcat and wait till it's status become running. We need to write a custom workflow step for it.
- Send Slack notifications, we can use the built-in [webhook-notification] step for it.
#
Step: Apply TomcatFirst, use vela def init
to generate a WorkflowStepDefinition
template:
The result is as follows:
Import vela/op
and complete the Cue code in template
:
Apply it to the cluster:
#
Step: Send Slack notificationsUse the built-in step, [webhook-notification].
#
Apply the ApplicationApply the Application to the cluster and you can see that all resources have been successfully applied and Slack has received the messages of the Deployment status.