Creating a Broker¶
Once you have installed Knative Eventing and a Broker implementation, you can create an instance of a Broker.
Note
Knative Eventing provides by default the MTChannelBasedBroker. Its default backing channel is the InMemoryChannel. InMemoryChannel should not be used in production. Other Broker types and their configuration options can be found under Available Broker types.
You can create a Broker by using the kn CLI or by applying YAML files using kubectl.
-
You can create a Broker by entering the following command:
kn broker create <broker-name> -n <namespace>This will create a new Broker of your default Broker class and default Broker configuration (both defined in the
config-br-defaultsConfigMap).Note
If you omit the namespace, the Broker is created in the current namespace. Omit the namespace flag in both verification commands too, or explicitly use that same namespace.
Note
If you have multiple Broker classes installed in your cluster, you can specify the Broker class via the
--classparameter, e.g.:kn broker create <broker-name> -n <namespace> --class MTChannelBasedBroker -
Verify the Broker in the same namespace used for creation:
kn broker list -n <namespace>Find
<broker-name>and check thatREADYisTrue. If it isFalse, wait and repeat the check, or inspect its condition messages below. -
Optional: You can also verify the Broker exists by describing the Broker you have created:
kn broker describe <broker-name> -n <namespace>
Supply the Broker name and namespace in this YAML template, then use those same values in the verification command.
-
Create a Broker by creating a YAML file using the following template:
apiVersion: eventing.knative.dev/v1 kind: Broker metadata: name: <broker-name> namespace: <namespace>This creates a new Broker using the default Broker class and default Broker configuration, both of which are defined in the
config-br-defaultsConfigMap. -
Apply the YAML file:
Wherekubectl apply -f <filename>.yaml<filename>is the name of the file you created in the previous step. -
Optional: Verify that the Broker is working correctly:
kubectl -n <namespace> get broker <broker-name>This shows information about your Broker. If the Broker is working correctly, it shows a
READYstatus ofTrue:NAME READY REASON URL AGE default True http://broker-ingress.knative-eventing.svc.cluster.local/default/default 1mIf the
READYstatus isFalse, wait a few moments and then run the command again.