Skip to content

Trigger

What is a trigger?

Trigger is the resource executed by sensor once the event dependencies are resolved. Any K8s resource can act as a trigger (Custom Resources included).

How to define a trigger?

The framework provides support to fetch trigger resources from different sources.

Inline

Inlined artifacts are included directly within the sensor resource and decoded as a string. Example

S3

Argo Events uses the minio-go client for access to any Amazon S3 compatible object store. Example

File

Artifacts are defined in a file that is mounted via a PersistentVolume within the sensor-controller pod. Example

URL

Artifacts are accessed from web via RESTful API. Example

Configmap

Artifacts stored in Kubernetes configmap are accessed using the key. Example

Git

Artifacts stored in either public or private Git repository. Example

Resource

Artifacts defined as generic K8s resource template. This is specially useful if you use tools like Kustomize to generate the sensor spec. Example

What resource types are supported out of box?

How to trigger standard Kubernetes Resource instead of Argo Workflow?

There could be a case where you may want to trigger a standard Kubernetes resource like Pod, Deployment etc. instead of an Argo Workflow. The sensor allows you to trigger any K8s resource the same way you would trigger an Argo Workflow.

  • The example showcases how you can trigger different standard K8s resources. You can find K8s API reference here.

  • To trigger other standard K8s resources, change the group and version in triggers/resource accordingly.

How can I add my custom resource as trigger?

The set of currently supported resources are implemented in the store package. You need to register your custom resource in order for sensor to be able to trigger it. Once you register your custom resource, you'll need to rebuild the sensor image.

Follow these steps,

  1. Go to store.go in store package.
  2. Import your custom resource api package.
  3. In init method, add the scheme to your custom resource api.
  4. Make sure there are no errors.
  5. Rebuild the sensor binary using make sensor
  6. To build the image, first change IMAGE_NAMESPACE in Makefile to your docker registry and then run make sensor-image.