Version: v1.2

Built-in Workflow Steps

This documentation will walk through the built-in workflow steps that you can use to design an application deployment process.

apply-application

Overview

Apply all components and traits in Application.

Parameter

No arguments, used for custom steps before or after application applied.

Example

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: first-vela-workflow
  5. namespace: default
  6. spec:
  7. components:
  8. - name: express-server
  9. type: webservice
  10. properties:
  11. image: crccheck/hello-world
  12. port: 8000
  13. traits:
  14. - type: ingress
  15. properties:
  16. domain: testsvc.example.com
  17. http:
  18. /: 8000
  19. workflow:
  20. steps:
  21. - name: express-server
  22. type: apply-application

depends-on-app

Overview

Wait for the specified Application to complete.

depends-on-app will check if the cluster has the application with name and namespace defines in properties. If the application exists, the next step will be executed after the application is running. If the application do not exists, KubeVela will check the ConfigMap with the same name, and read the config of the Application and apply to cluster. The ConfigMap is like below: the name and namespace of the ConfigMap is the same in properties. In data, the key is name, and the value is the yaml of the deployed application yaml.

  1. apiVersion: v1
  2. kind: ConfigMap
  3. metadata:
  4. name: myapp
  5. namespace: vela-system
  6. data:
  7. myapp: ...

Parameter

NameTypeDescription
namestringThe name of the Application
namespacestringThe namespace of the Application

Example

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: first-vela-workflow
  5. namespace: default
  6. spec:
  7. components:
  8. - name: express-server
  9. type: webservice
  10. properties:
  11. image: crccheck/hello-world
  12. port: 8000
  13. traits:
  14. - type: ingress
  15. properties:
  16. domain: testsvc.example.com
  17. http:
  18. /: 8000
  19. workflow:
  20. steps:
  21. - name: express-server
  22. type: depends-on-app
  23. properties:
  24. name: another-app
  25. namespace: default

deploy2env

Overview

Apply Application in different policies and envs.

Parameter

NameTypeDescription
policystringThe name of the policy
envstringThe name of the env

Example

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: multi-env-demo
  5. namespace: default
  6. spec:
  7. components:
  8. - name: nginx-server
  9. type: webservice
  10. properties:
  11. image: nginx:1.21
  12. port: 80
  13. policies:
  14. - name: env
  15. type: env-binding
  16. properties:
  17. created: false
  18. envs:
  19. - name: test
  20. patch:
  21. components:
  22. - name: nginx-server
  23. type: webservice
  24. properties:
  25. image: nginx:1.20
  26. port: 80
  27. placement:
  28. namespaceSelector:
  29. name: test
  30. - name: prod
  31. patch:
  32. components:
  33. - name: nginx-server
  34. type: webservice
  35. properties:
  36. image: nginx:1.20
  37. port: 80
  38. placement:
  39. namespaceSelector:
  40. name: prod
  41. workflow:
  42. steps:
  43. - name: deploy-test-server
  44. type: deploy2env
  45. properties:
  46. policy: env
  47. env: test
  48. - name: deploy-prod-server
  49. type: deploy2env
  50. properties:
  51. policy: env
  52. env: prod

notification

Overview

Send notifications. You can use the notification to send email, slack, ding talk and lark.

Parameters

NameTypeDescription
emailObjectOptional, please fulfill its from, to and content if you want to send email
email.from.addressStringRequired, the email address that you want to send from
email.from.aliasStringOptional, the email alias to show after sending the email
email.from.passwordValueOrSecretRequired, the password of the email, you can either specify it in value or use secretRef
email.from.hostStringRequired, the host of your email
email.from.portIntOptional, the port of the email host, default to 587
email.to[]StringRequired, the email address that you want to send to
email.content.subjectStringRequired, the subject of the email
email.content.bodyStringRequired, the context body of the email
slackObjectOptional, please fulfill its url and message if you want to send Slack messages
slack.urlValueOrSecretRequired, the webhook address of Slack, you can choose to fill it directly in value or specify it in secret
slack.messageObjectRequired, the Slack messages you want to send, please follow Slack messaging
dingdingObjectOptional, please fulfill its url and message if you want to send DingTalk messages
dingding.urlValueOrSecretRequired, the webhook address of DingTalk, you can choose to fill it directly in value or specify it in secret
dingding.messageObjectRequired, the DingTalk messages you want to send, please follow DingTalk messaging
larkObjectOptional, please fulfill its url and message if you want to send Lark messages
lark.urlValueOrSecretRequired, the webhook address of Lark, you can choose to fill it directly in value or specify it in secret
lark.messageObjectRequired, the Lark messages you want to send, please follow Lark messaging

The ValueOrSecret format is:

NameTypeDescription
valueStringOptional, directly get the data from value
secretRef.nameStringOptional, get data from secret, the name of the secret
secretRef.keyStringOptional, get data from secret, the key of the secret

Example

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: first-vela-workflow
  5. namespace: default
  6. spec:
  7. components:
  8. - name: express-server
  9. type: webservice
  10. properties:
  11. image: crccheck/hello-world
  12. port: 8000
  13. traits:
  14. - type: ingress
  15. properties:
  16. domain: testsvc.example.com
  17. http:
  18. /: 8000
  19. workflow:
  20. steps:
  21. - name: dingtalk-message
  22. type: notification
  23. properties:
  24. dingding:
  25. # the DingTalk webhook address, please refer to: https://developers.dingtalk.com/document/robots/custom-robot-access
  26. url:
  27. value: <url>
  28. message:
  29. msgtype: text
  30. text:
  31. context: Workflow starting...
  32. - name: application
  33. type: apply-application
  34. - name: slack-message
  35. type: notification
  36. properties:
  37. slack:
  38. # the Slack webhook address, please refer to: https://api.slack.com/messaging/webhooks
  39. url:
  40. secretRef:
  41. name: <secret-key>
  42. key: <secret-value>
  43. message:
  44. text: Workflow ended.
  45. lark:
  46. url:
  47. value: <lark-url>
  48. message:
  49. msg_type: "text"
  50. content: "{\"text\":\" Hello KubeVela\"}"
  51. email:
  52. from:
  53. address: <sender-email-address>
  54. alias: <sender-alias>
  55. password:
  56. # secretRef:
  57. # name: <secret-name>
  58. # key: <secret-key>
  59. value: <sender-password>
  60. host: <email host like smtp.gmail.com>
  61. port: <email port, optional, default to 587>
  62. to:
  63. - kubevela1@gmail.com
  64. - kubevela2@gmail.com
  65. content:
  66. subject: test-subject
  67. body: test-body

apply-object

Overview

Apply Kubernetes native resources, you need to upgrade to KubeVela v1.1.4 or higher to enable apply-object.

Parameters

NameTypeDescription
valueObjectRequired, Kubernetes native resources fields
clusterStringOptional, The cluster you want to apply the resource to, default is the current cluster. If you want to apply resource in different cluster, use vela cluster join to join the cluster first, and then specify the cluster

Example

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: server-with-pvc
  5. namespace: default
  6. spec:
  7. components:
  8. - name: express-server
  9. type: webservice
  10. properties:
  11. image: crccheck/hello-world
  12. port: 8000
  13. volumes:
  14. - name: "my-pvc"
  15. type: "pvc"
  16. mountPath: "/test"
  17. claimName: "myclaim"
  18. workflow:
  19. steps:
  20. - name: apply-pvc
  21. type: apply-object
  22. properties:
  23. # Kubernetes native resources fields
  24. value:
  25. apiVersion: v1
  26. kind: PersistentVolumeClaim
  27. metadata:
  28. name: myclaim
  29. namespace: default
  30. spec:
  31. accessModes:
  32. - ReadWriteOnce
  33. resources:
  34. requests:
  35. storage: 8Gi
  36. storageClassName: standard
  37. # the cluster you want to apply the resource to, default is the current cluster
  38. cluster: <your cluster name>
  39. - name: apply-server
  40. type: apply-component
  41. properties:
  42. component: express-serve

read-object

Overview

Read Kubernetes native resources, you need to upgrade to KubeVela v1.1.6 or higher to enable read-object.

Parameters

NameTypeDescription
apiVersionStringRequired, The apiVersion of the resource you want to read
kindStringRequired, The kind of the resource you want to read
nameStringRequired, The apiVersion of the resource you want to read
namespaceStringOptional, The namespace of the resource you want to read, defaults to default
clusterStringOptional, The cluster you want to read the resource from, default is the current cluster. If you want to read resource in different cluster, use vela cluster join to join the cluster first, and then specify the cluster

Example

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: read-object
  5. namespace: default
  6. spec:
  7. components:
  8. - name: express-server
  9. type: webservice
  10. properties:
  11. image: crccheck/hello-world
  12. port: 8000
  13. workflow:
  14. steps:
  15. - name: read-object
  16. type: read-object
  17. outputs:
  18. - name: cpu
  19. valueFrom: output.value.data["cpu"]
  20. - name: memory
  21. valueFrom: output.value.data["memory"]
  22. properties:
  23. apiVersion: v1
  24. kind: ConfigMap
  25. name: my-cm-name
  26. cluster: <your cluster name
  27. - name: apply
  28. type: apply-component
  29. inputs:
  30. - from: cpu
  31. parameterKey: cpu
  32. - from: memory
  33. parameterKey: memory
  34. properties:
  35. component: express-server

export2config

Overview

Export data to ConfigMap, you need to upgrade to KubeVela v1.1.6 or higher to enable export2config.

Parameters

NameTypeDescription
configNameStringRequired, The name of the ConfigMap
namespaceStringOptional, The namespace of the ConfigMap, defaults to context.namespace
dataMapRequired, The data that you want to export to ConfigMap

Example

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: export-config
  5. namespace: default
  6. spec:
  7. components:
  8. - name: express-server
  9. type: webservice
  10. properties:
  11. image: crccheck/hello-world
  12. port: 8000
  13. workflow:
  14. steps:
  15. - name: apply-server
  16. type: apply-component
  17. outputs:
  18. - name: status
  19. valueFrom: output.status.conditions[0].message
  20. properties:
  21. component: express-server
  22. - name: export-config
  23. type: export-config
  24. inputs:
  25. - from: status
  26. parameterKey: data.serverstatus
  27. properties:
  28. configName: my-configmap
  29. data:
  30. testkey: testvalue

export2secret

Overview

Export data to Secret, you need to upgrade to KubeVela v1.1.6 or higher to enable export2secret.

Parameters

NameTypeDescription
secretNameStringRequired, The name of the Secret
namespaceStringOptional, The namespace of the Secret, defaults to context.namespace
dataMapRequired, The data that you want to export to Secret

Example

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: export-secret
  5. namespace: default
  6. spec:
  7. components:
  8. - name: express-server
  9. type: webservice
  10. properties:
  11. image: crccheck/hello-world
  12. port: 8000
  13. workflow:
  14. steps:
  15. - name: apply-server
  16. type: apply-component
  17. outputs:
  18. - name: status
  19. valueFrom: output.status.conditions[0].message
  20. properties:
  21. component: express-server
  22. - name: export-secret
  23. type: export-secret
  24. inputs:
  25. - from: status
  26. parameterKey: data.serverstatus
  27. properties:
  28. secretName: my-secret
  29. data:
  30. testkey: testvalue

suspend

Overview

Suspend the current workflow, we can use vela workflow resume appname to resume the suspended workflow.

For more information of vela workflow, please refer to vela cli

Parameter

NameTypeDescription
---

Example

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: first-vela-workflow
  5. namespace: default
  6. spec:
  7. components:
  8. - name: express-server
  9. type: webservice
  10. properties:
  11. image: crccheck/hello-world
  12. port: 8000
  13. traits:
  14. - type: ingress
  15. properties:
  16. domain: testsvc.example.com
  17. http:
  18. /: 8000
  19. workflow:
  20. steps:
  21. - name: slack-message
  22. type: webhook-notification
  23. properties:
  24. slack:
  25. # the Slack webhook address, please refer to: https://api.slack.com/messaging/webhooks
  26. message:
  27. text: Ready to apply the application, ask the administrator to approve and resume the workflow.
  28. - name: manual-approval
  29. type: suspend
  30. - name: express-server
  31. type: apply-application