Version: v1.3

Built-in Workflow Steps

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

Overview

Deploy components with policies.

Parameter

NameTypeDescription
autoboolOptional, default to true. If set to false, the workflow will suspend automatically before this step.
policies[]stringOptional, the policies that used for this deployment. If not specified, the components will be deployed to the hub cluster.
parallelismintOptional, defaults to 5.

Example

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: deploy-workflowstep
  5. namespace: examples
  6. spec:
  7. components:
  8. - name: nginx-deploy-workflowstep
  9. type: webservice
  10. properties:
  11. image: nginx
  12. policies:
  13. - name: topology-hangzhou-clusters
  14. type: topology
  15. properties:
  16. clusterLabelSelector:
  17. region: hangzhou
  18. - name: topology-local
  19. type: topology
  20. properties:
  21. clusters: ["local"]
  22. namespace: examples-alternative
  23. workflow:
  24. steps:
  25. - type: deploy
  26. name: deploy-local
  27. properties:
  28. policies: ["topology-local"]
  29. - type: deploy
  30. name: deploy-hangzhou
  31. properties:
  32. # require manual approval before running this step
  33. auto: false
  34. policies: ["topology-hangzhou-clusters"]

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

Notice that you need to upgrade to KubeVela v1.4 or higher to use duration parameter.

NameTypeDescription
durationstringOptional, the wait duration time to resume workflow such as “30s”, “1min” or “2m15s”

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: oamdev/hello-world
  12. port: 8000
  13. workflow:
  14. steps:
  15. - name: slack-message
  16. type: webhook-notification
  17. properties:
  18. slack:
  19. # the Slack webhook address, please refer to: https://api.slack.com/messaging/webhooks
  20. message:
  21. text: Ready to apply the application, ask the administrator to approve and resume the workflow.
  22. - name: manual-approval
  23. type: suspend
  24. # properties:
  25. # duration: "30s"
  26. - name: express-server
  27. type: apply-application

Overview

Send notifications. You can use the notification to send notifications to Email, DingTalk, Slack, 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: oamdev/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
  • Expected outcome

we can see that before and after the deployment of the application, the messages can be seen in the corresponding group chat.

Overview

Send a request to the specified Webhook URL. If no request body is specified, the current Application body will be sent by default.

Parameter

NameTypeDescription
urlValueOrSecretRequired, Webhook URL to be sent, you can choose to fill in value directly or get it from secretRef
dataobjectOptional, the data that needs to be sent

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: oamdev/hello-world
  12. port: 8000
  13. workflow:
  14. steps:
  15. - name: express-server
  16. type: apply-application
  17. - name: webhook
  18. type: webhook
  19. properties:
  20. url:
  21. value: <your webhook url>

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: oamdev/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

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: oamdev/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

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: oamdev/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

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: oamdev/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

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: oamdev/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

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: oamdev/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

Last updated on Nov 1, 2022 by Tianxin Dong