×

Using the Knative (kn) CLI to create triggers provides a more streamlined and intuitive user interface over modifying YAML files directly.

Creating a trigger by using the Knative CLI

You can use the kn trigger create command to create a trigger.

Prerequisites
  • The OpenShift Serverless Operator and Knative Eventing are installed on your Red Hat OpenShift Service on AWS cluster.

  • You have installed the Knative (kn) CLI.

  • You have created a project or have access to a project with the appropriate roles and permissions to create applications and other workloads in Red Hat OpenShift Service on AWS.

Procedure
  • Create a trigger:

    $ kn trigger create <trigger_name> --broker <broker_name> --filter <key=value> --sink <sink_name>

    Alternatively, you can create a trigger and simultaneously create the default broker using broker injection:

    $ kn trigger create <trigger_name> --inject-broker --filter <key=value> --sink <sink_name>

    By default, triggers forward all events sent to a broker to sinks that are subscribed to that broker. Using the --filter attribute for triggers allows you to filter events from a broker, so that subscribers will only receive a subset of events based on your defined criteria.