$ kn broker create <broker_name>
Knative provides a default, channel-based broker implementation. This channel-based broker can be used for development and testing purposes, but does not provide adequate event delivery guarantees for production environments.
If a cluster administrator has configured your OpenShift Serverless deployment to use Kafka as the default broker type, creating a broker by using the default settings creates a Kafka-based broker.
If your OpenShift Serverless deployment is not configured to use Kafka broker as the default broker type, the channel-based broker is created when you use the default settings in the following procedures.
Brokers can be used in combination with triggers to deliver events from an event source to an event sink. Using the Knative (kn
) cli to create brokers provides a more streamlined and intuitive user interface over modifying YAML files directly. You can use the kn broker create
command to create a broker.
The OpenShift Serverless Operator and Knative Eventing are installed on your OpenShift Container Platform 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 OpenShift Container Platform.
Create a broker:
$ kn broker create <broker_name>
Use the kn
command to list all existing brokers:
$ kn broker list
NAME URL AGE CONDITIONS READY REASON
default http://broker-ingress.knative-eventing.svc.cluster.local/test/default 45s 5 OK / 5 True
Optional: If you are using the OpenShift Container Platform web console, you can navigate to the Topology view in the Developer perspective, and observe that the broker exists:
Brokers can be used in combination with triggers to deliver events from an event source to an event sink. You can create a broker by adding the eventing.knative.dev/injection: enabled
annotation to a Trigger
object.
If you create a broker by using the |
The OpenShift Serverless Operator and Knative Eventing are installed on your OpenShift Container Platform cluster.
Install the OpenShift cli (oc
).
You have created a project or have access to a project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
Create a Trigger
object as a YAML file that has the eventing.knative.dev/injection: enabled
annotation:
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
annotations:
eventing.knative.dev/injection: enabled
name: <trigger_name>
spec:
broker: default
subscriber: (1)
ref:
apiVersion: serving.knative.dev/v1
kind: Service
name: <service_name>
1 | Specify details about the event sink, or subscriber, that the trigger sends events to. |
Apply the Trigger
YAML file:
$ oc apply -f <filename>
You can verify that the broker has been created successfully by using the oc
cli, or by observing it in the Topology view in the web console.
Enter the following oc
command to get the broker:
$ oc -n <namespace> get broker default
NAME READY REASON URL AGE
default True http://broker-ingress.knative-eventing.svc.cluster.local/test/default 3m56s
Optional: If you are using the OpenShift Container Platform web console, you can navigate to the Topology view in the Developer perspective, and observe that the broker exists:
Brokers can be used in combination with triggers to deliver events from an event source to an event sink. You can create the default
broker automatically by labelling a namespace that you own or have write permissions for.
Brokers created using this method are not removed if you remove the label. You must manually delete them. |
The OpenShift Serverless Operator and Knative Eventing are installed on your OpenShift Container Platform cluster.
Install the OpenShift cli (oc
).
You have created a project or have access to a project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
Label a namespace with eventing.knative.dev/injection=enabled
:
$ oc label namespace <namespace> eventing.knative.dev/injection=enabled
You can verify that the broker has been created successfully by using the oc
cli, or by observing it in the Topology view in the web console.
Use the oc
command to get the broker:
$ oc -n <namespace> get broker <broker_name>
$ oc -n default get broker default
NAME READY REASON URL AGE
default True http://broker-ingress.knative-eventing.svc.cluster.local/test/default 3m56s
Optional: If you are using the OpenShift Container Platform web console, you can navigate to the Topology view in the Developer perspective, and observe that the broker exists:
If you create a broker by injection and later want to delete it, you must delete it manually. Brokers created by using a namespace label or trigger annotation are not deleted permanently if you remove the label or annotation.
Install the OpenShift cli (oc
).
Remove the eventing.knative.dev/injection=enabled
label from the namespace:
$ oc label namespace <namespace> eventing.knative.dev/injection-
Removing the annotation prevents Knative from recreating the broker after you delete it.
Delete the broker from the selected namespace:
$ oc -n <namespace> delete broker <broker_name>
Use the oc
command to get the broker:
$ oc -n <namespace> get broker <broker_name>
$ oc -n default get broker default
No resources found.
Error from server (NotFound): brokers.eventing.knative.dev "default" not found
If your OpenShift Serverless deployment is not configured to use Kafka broker as the default broker type, you can use one of the following procedures to create a Kafka-based broker.
Creating Knative resources by using YAML files uses a declarative API, which enables you to describe applications declaratively and in a reproducible manner. To create a Kafka broker by using YAML, you must create a YAML file that defines a Broker
object, then apply it by using the oc apply
command.
The OpenShift Serverless Operator, Knative Eventing, and the KnativeKafka
custom resource are installed on your OpenShift Container Platform cluster.
You have created a project or have access to a project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
You have installed the OpenShift cli (oc
).
Create a Kafka-based broker as a YAML file:
apiVersion: eventing.knative.dev/v1
kind: Broker
metadata:
annotations:
eventing.knative.dev/broker.class: Kafka (1)
name: example-kafka-broker
spec:
config:
apiVersion: v1
kind: ConfigMap
name: kafka-broker-config (2)
namespace: knative-eventing
1 | The broker class. If not specified, brokers use the default class as configured by cluster administrators. To use the Kafka broker, this value must be Kafka . |
2 | The default config map for Knative Kafka brokers. This config map is created when the Kafka broker functionality is enabled on the cluster by a cluster administrator. |
Apply the Kafka-based broker YAML file:
$ oc apply -f <filename>
If you want to use a Kafka broker without allowing it to create its own internal topic, you can use an externally managed Kafka topic instead. To do this, you must create a Kafka Broker
object that uses the kafka.eventing.knative.dev/external.topic
annotation.
The OpenShift Serverless Operator, Knative Eventing, and the KnativeKafka
custom resource are installed on your OpenShift Container Platform cluster.
You have access to a Kafka instance such as Red Hat AMQ Streams, and have created a Kafka topic.
You have created a project or have access to a project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
You have installed the OpenShift cli (oc
).
Create a Kafka-based broker as a YAML file:
apiVersion: eventing.knative.dev/v1
kind: Broker
metadata:
annotations:
eventing.knative.dev/broker.class: Kafka (1)
kafka.eventing.knative.dev/external.topic: <topic_name> (2)
...
1 | The broker class. If not specified, brokers use the default class as configured by cluster administrators. To use the Kafka broker, this value must be Kafka . |
2 | The name of the Kafka topic that you want to use. |
Apply the Kafka-based broker YAML file:
$ oc apply -f <filename>
The Knative (kn
) cli provides commands that can be used to describe and list existing brokers.
Using the Knative (kn
) cli to list brokers provides a streamlined and intuitive user interface. You can use the kn broker list
command to list existing brokers in your cluster by using the Knative cli.
The OpenShift Serverless Operator and Knative Eventing are installed on your OpenShift Container Platform cluster.
You have installed the Knative (kn
) cli.
List all existing brokers:
$ kn broker list
NAME URL AGE CONDITIONS READY REASON
default http://broker-ingress.knative-eventing.svc.cluster.local/test/default 45s 5 OK / 5 True
Using the Knative (kn
) cli to describe brokers provides a streamlined and intuitive user interface. You can use the kn broker describe
command to print information about existing brokers in your cluster by using the Knative cli.
The OpenShift Serverless Operator and Knative Eventing are installed on your OpenShift Container Platform cluster.
You have installed the Knative (kn
) cli.
Describe an existing broker:
$ kn broker describe <broker_name>
$ kn broker describe default
Name: default
Namespace: default
Annotations: eventing.knative.dev/broker.class=MTChannelBasedBroker, eventing.knative.dev/creato ...
Age: 22s
Address:
URL: http://broker-ingress.knative-eventing.svc.cluster.local/default/default
Conditions:
OK TYPE AGE REASON
++ Ready 22s
++ Addressable 22s
++ FilterReady 22s
++ IngressReady 22s
++ TriggerChannelReady 22s
Configure event delivery parameters that are applied in cases where an event fails to be delivered to an event sink. See Examples of configuring event delivery parameters.