Dependency

This section will introduce how to specify dependencies for workflow steps.

Dependency - 图1note

In the version <=1.4, the steps in the workflow are executed sequentially, which means that there is an implicit dependency between steps, ie: the next step depends on the successful execution of the previous step. At this point, specifying dependencies in the workflow may not make much sense.

In versions 1.5+, you can display the execution method of the specified workflow steps (eg: change to DAG parallel execution). At this time, you can control the execution of the workflow by specifying the dependencies of the steps.

In KubeVela, the dependencies between steps can be specified by dependsOn in the steps.

For example: we want to send a message notification after deploying the component:

  1. ...
  2. workflow:
  3. steps:
  4. - name: comp
  5. type: apply-component
  6. - name: notify
  7. type: notification
  8. dependsOn:
  9. - comp

In this case, KubeVela waits for the completion of the step comp before executing the notify step to send a message notification.

Apply the following YAML:

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: dependsOn-app
  5. namespace: default
  6. spec:
  7. components:
  8. - name: express-server
  9. type: webservice
  10. properties:
  11. image: oamdev/hello-world
  12. ports:
  13. - port: 8000
  14. workflow:
  15. steps:
  16. - name: comp
  17. type: apply-component
  18. properties:
  19. component: express-server
  20. - name: slack-message
  21. type: notification
  22. dependsOn:
  23. - comp
  24. properties:
  25. slack:
  26. url:
  27. value: <your slack url>
  28. message:
  29. text: depends on comp

Use vela status to check the status of the Application:

  1. $ vela status depends
  2. About:
  3. Name: depends
  4. Namespace: default
  5. Created at: 2022-06-24 17:20:50 +0800 CST
  6. Status: running
  7. Workflow:
  8. mode: StepByStep
  9. finished: true
  10. Suspend: false
  11. Terminated: false
  12. Steps
  13. - id:e6votsntq3
  14. name:comp
  15. type:apply-component
  16. phase:succeeded
  17. message:
  18. - id:esvzxehgwc
  19. name:slack-message
  20. type:notification
  21. phase:succeeded
  22. message:
  23. Services:
  24. - Name: express-server
  25. Cluster: local Namespace: default
  26. Type: webservice
  27. Healthy Ready:1/1
  28. No trait applied

As you can see, all step statuses are succeeded. And when the component is successfully deployed, a message is also sent in slack.

Last updated on Aug 4, 2023 by Daniel Higuero