Argo Workflow Trigger¶
Argo workflow is K8s custom resource which help orchestrating parallel jobs on Kubernetes.
Trigger a workflow¶
Note: You will need to have Argo Workflows installed to make this work.
-
Make sure to have the eventbus deployed in the namespace.
-
We will use webhook event-source and sensor to trigger an Argo workflow.
-
Set up the
operate-workflow-sa
service account that the sensor will usekubectl apply -n argo-events -f https://raw.githubusercontent.com/argoproj/argo-events/master/examples/rbac/sensor-rbac.yaml
-
Let's set up a webhook event-source to process incoming requests.
kubectl apply -n argo-events -f https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/event-sources/webhook.yaml
-
Create the sensor.
kubectl apply -n argo-events -f https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/sensors/special-workflow-trigger-shortened.yaml
-
Let's expose the webhook event-source pod using
port-forward
so that we can make a request to it.kubectl -n argo-events port-forward <name-of-event-source-pod> 12000:12000
-
Use either Curl or Postman to send a post request to the
http://localhost:12000/example
.curl -d '{"message":"ok"}' -H "Content-Type: application/json" -X POST http://localhost:12000/example
-
List the workflow using
argo list
.
Parameterization¶
Similar to other type of triggers, sensor offers parameterization for the Argo workflow trigger. Parameterization is specially useful when you want to define a generic trigger template in the sensor and populate the workflow object values on the fly.
You can learn more about trigger parameterization here.
Policy¶
Trigger policy helps you determine the status of the triggered Argo workflow object and decide whether to stop or continue sensor.
Take a look at K8s Trigger Policy.
Argo CLI¶
In addition to the example above, you can leverage other functionalities provided by the Argo CLI such as,
- Submit
- Submit --from
- Resubmit
- Resume
- Retry
- Suspend
- Terminate
- Stop
To make use of Argo CLI operations in argoWorkflow
trigger template,
argoWorkflow:
operation: submit # submit, submit-from, resubmit, resume, retry, suspend, terminate or stop
Complete example is available here.