Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Update events.md #6119

Merged
merged 1 commit into from
Jun 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update events.md
Trying to use the argo workflows events and I noticed that some crucial explanations are missing here. I would like to add:
- A simple WorkflowTemplate bound to the WorkflowEventBinding, to show what is triggered by the curl that send the event
- Some infos about the process that bind the event to the workflow template:
   - template creation
   - event binding apply
   - api call to trigger the workflow template creation
Plus: there is a little mistake in the selector:  metadata["x-argo"] instead of metadata["X-Argo-E2E"] I would like to correct it in order to avoid mistakes during the curl.

Hope this is appreciated! ;)

Denis
  • Loading branch information
debellotti committed Jun 10, 2021
commit cf541eecead0918d97d2542d9274c1a38b8e5cc0
35 changes: 34 additions & 1 deletion docs/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,31 @@ The event endpoint will always return in under 10 seconds because the event will
!!! Warning "Processing Order"
Events may not always be processed in the order they are received.

## Workflow Template triggered by the event

Before the binding between an event and a workflow template, you must create the workflow template that you want to trigger.
The following one takes in input the "message" parameter specified into the API call body, passed through the WorkflowEventBinding parameters section, and finally resolved here as the message of the whalesay image.

```
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: my-wf-tmple
namespace: argo
spec:
templates:
- name: main
inputs:
parameters:
- name: message
value: "{{workflow.parameters.message}}"
container:
image: docker/whalesay:latest
command: [cowsay]
args: ["{{inputs.parameters.message}}"]
entrypoint: main
```

## Submitting A Workflow From A Workflow Template

A workflow template will be submitted (i.e. workflow created from it) and that can be created using parameters from the event itself.
Expand All @@ -51,7 +76,7 @@ metadata:
name: event-consumer
spec:
event:
selector: payload.message != "" && metadata["x-argo"] == ["true"] && discriminator == "my-discriminator"
selector: payload.message != "" && metadata["X-Argo-E2E"] == ["true"] && discriminator == "my-discriminator"
submit:
workflowTemplateRef:
name: my-wf-tmple
Expand All @@ -61,6 +86,14 @@ spec:
valueFrom:
event: payload.message
```
Please, notice that "workflowTemplateRef" refers to a template with the name "my-wf-tmple", this template has to be created before the triggering of the event.
After that you have to apply the above explained WorkflowEventBinding (in this example this is called event-template.yml) to realize the binding between Workflow Template and event (you can use kubectl to do that):

```
kubectl apply -f event-template.yml
```

Finally you can trigger the creation of your first parametrized workflow template, by using the following call:

Event:

Expand Down