Triggers

A Trigger represents a desire to subscribe to events from a specific Broker.

The subscriber value must be a Destination.

Simple example which will receive all the events from the given (default) broker and deliver them to Knative Serving service my-service:

  1. kubectl create -f - <<EOF
  2. apiVersion: eventing.knative.dev/v1
  3. kind: Trigger
  4. metadata:
  5. name: my-service-trigger
  6. spec:
  7. broker: default
  8. subscriber:
  9. ref:
  10. apiVersion: serving.knative.dev/v1
  11. kind: Service
  12. name: my-service
  13. EOF

Simple example which will receive all the events from the given (default) broker and deliver them to the custom path /my-custom-path for the Kubernetes service my-service:

  1. kubectl create -f - <<EOF
  2. apiVersion: eventing.knative.dev/v1
  3. kind: Trigger
  4. metadata:
  5. name: my-service-trigger
  6. spec:
  7. broker: default
  8. subscriber:
  9. ref:
  10. apiVersion: v1
  11. kind: Service
  12. name: my-service
  13. uri: /my-custom-path
  14. EOF

Trigger Filtering

Exact match filtering on any number of CloudEvents attributes as well as extensions are supported. If your filter sets multiple attributes, an event must have all of the attributes for the Trigger to filter it. Note that we only support exact matching on string values.

Example:

  1. kubectl create -f - <<EOF
  2. apiVersion: eventing.knative.dev/v1
  3. kind: Trigger
  4. metadata:
  5. name: my-service-trigger
  6. spec:
  7. broker: default
  8. filter:
  9. attributes:
  10. type: dev.knative.foo.bar
  11. myextension: my-extension-value
  12. subscriber:
  13. ref:
  14. apiVersion: serving.knative.dev/v1
  15. kind: Service
  16. name: my-service
  17. EOF

The example above filters events from the default Broker that are of type dev.knative.foo.bar AND have the extension myextension with the value my-extension-value.