1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 21:46:22 +01:00
Files
openshift-docs/modules/serverless-create-kn-trigger.adoc
2022-02-14 13:56:49 +00:00

35 lines
1.2 KiB
Plaintext

// Module included in the following assemblies:
//
// * /serverless/develop/serverless-triggers.adoc
:_content-type: PROCEDURE
[id="serverless-create-kn-trigger_{context}"]
= Creating a trigger by using the Knative CLI
You can create a trigger by using the `kn trigger create` command.
.Prerequisites
* The {ServerlessOperatorName} and Knative Eventing are installed on your {product-title} cluster.
* You have installed the `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 {product-title}.
.Procedure
* Create a trigger:
+
[source,terminal]
----
$ 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:
+
[source,terminal]
----
$ 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.