Trigger Sources¶
A trigger source is the source of trigger resource. It can be either external source such
as Git
, S3
, K8s Configmap
, File
, any valid URL
that hosts the resource or an internal resource
which is defined in the sensor object itself like Inline
or Resource
.
In the previous sections, you have been dealing with the Resource
trigger source. In this tutorial, we will explore other trigger sources.
Prerequisites¶
- The
Webhook
event-source is already set up.
Git¶
Git trigger source refers to K8s trigger refers to the K8s resource stored in Git.
The specification for the Git source is available here.
-
In order to fetch data from git, you need to set up the private SSH key in sensor.
-
If you don't have ssh keys available, create them following this guide.
-
Create a K8s secret that holds the SSH keys.
kubectl -n argo-events create secret generic git-ssh --from-file=key=.ssh/<YOUR_SSH_KEY_FILE_NAME>
-
Create a K8s secret that holds known hosts.
kubectl -n argo-events create secret generic git-known-hosts --from-file=ssh_known_hosts=.ssh/known_hosts
-
Create a sensor with the git trigger source and refer it to the
hello world
workflow stored on the Argo Git project.kubectl -n argo-events apply -f https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/tutorials/03-trigger-sources/sensor-git.yaml
-
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
-
Now, you should see an Argo workflow being created.
kubectl -n argo-events get wf
S3¶
You can refer to the K8s resource stored on S3 compliant store as the trigger source.
For this tutorial, lets set up a minio server which is S3 compliant store.
-
Create a K8s secret called
artifacts-minio
that holds your minio access key and secret key. The access key must be stored underaccesskey
key and secret key must be stored undersecretkey
. -
Follow steps described here to set up the minio server.
-
Make sure a service is available to expose the minio server.
-
Create a bucket called
workflows
and store a basichello world
Argo workflow with key namehello-world.yaml
. -
Create the sensor with trigger source as S3.
kubectl -n argo-events apply -f https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/tutorials/03-trigger-sources/sensor-minio.yaml
-
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
-
Now, you should see an Argo workflow being created.
kubectl -n argo-events get wf
K8s Configmap¶
K8s configmap can be treated as trigger source if needed.
-
Lets create a configmap called
trigger-store
.kubectl -n argo-events apply -f https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/tutorials/03-trigger-sources/trigger-store.yaml
-
Create a sensor with trigger source as configmap and refer it to the
trigger-store
.kubectl -n argo-events apply -f https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/tutorials/03-trigger-sources/sensor-cm.yaml
-
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
-
Now, you should see an Argo workflow being created.
kubectl -n argo-events get wf
File & URL¶
File and URL trigger sources are pretty self explanatory. The example sensors are available under examples/sensors folder.