Default Broker ConfigMap

NOTE: This guide assumes Knative Eventing is installed in the knative-eventing namespace. If you have installed Knative Eventing in a different namespace, replace default with the name of that namespace.

Knative Eventing provides a config-br-defaults ConfigMap, which provides default configuration settings to enable the creation of Brokers and Channels.

If you are using the config-br-defaults ConfigMap default configuration, the example below will create a Broker called default in the default namespace, and uses MTChannelBasedBroker as the implementation.

  1. kubectl create -f - <<EOF
  2. apiVersion: eventing.knative.dev/v1
  3. kind: Broker
  4. metadata:
  5. name: default
  6. namespace: default
  7. EOF

The following example shows a Broker where the configuration is specified in a ConfigMap config-br-default-channel:

  1. apiVersion: eventing.knative.dev/v1
  2. kind: Broker
  3. metadata:
  4. annotations:
  5. eventing.knative.dev/broker.class: MTChannelBasedBroker
  6. name: default
  7. spec:
  8. # Configuration specific to this broker.
  9. config:
  10. apiVersion: v1
  11. kind: ConfigMap
  12. name: config-br-default-channel
  13. namespace: knative-eventing

Format of the file

Let’s look at the ConfigMap that comes out of the box when you install a release (v0.16.0 in this example):

  1. apiVersion: v1
  2. kind: ConfigMap
  3. metadata:
  4. name: config-br-defaults
  5. namespace: knative-eventing
  6. labels:
  7. eventing.knative.dev/release: devel
  8. data:
  9. # Configuration for defaulting channels that do not specify CRD implementations.
  10. default-br-config: |
  11. clusterDefault:
  12. brokerClass: MTChannelBasedBroker
  13. apiVersion: v1
  14. kind: ConfigMap
  15. name: config-br-default-channel
  16. namespace: knative-eventing

This means that any Broker created without a specific BrokerClass annotation will use MTChannelBasedBroker, and any Broker without a spec.config will have spec.config like so:

  1. spec:
  2. config:
  3. apiVersion: v1
  4. kind: ConfigMap
  5. name: config-br-default-channel
  6. namespace: knative-eventing

Changing the default BrokerClass

Changing the default BrokerClass for the cluster

If you have installed a different Broker, or multiple, you can change the default Broker used at the cluster level and by namespace. If you for example have installed MT Channel Based Broker as well as YourBroker and would prefer that by default any Broker created uses YourBroker you could modify the ConfigMap to look like this:

  1. apiVersion: v1
  2. kind: ConfigMap
  3. metadata:
  4. name: config-br-defaults
  5. namespace: knative-eventing
  6. labels:
  7. eventing.knative.dev/release: devel
  8. data:
  9. # Configuration for defaulting channels that do not specify CRD implementations.
  10. default-br-config: |
  11. clusterDefault:
  12. brokerClass: YourBroker

Now every Broker created in the cluster without the BrokerClass annotation will be using YourBroker as the Broker implementation. Note that you can always use a different implementation by explicitly specifying the BrokerClass annotation when you create a Broker.

Changing the default BrokerClass for namespaces

As mentioned, you can also control the defaulting behaviour for some set of namespaces. So, if for example, you wanted to use YourBroker for all the other Brokers created, but wanted to use MTChannelBasedBroker for the following namespaces: namespace1 and namespace2. You would modify the config map like this:

  1. apiVersion: v1
  2. kind: ConfigMap
  3. metadata:
  4. name: config-br-defaults
  5. namespace: knative-eventing
  6. labels:
  7. eventing.knative.dev/release: devel
  8. data:
  9. # Configuration for defaulting channels that do not specify CRD implementations.
  10. default-br-config: |
  11. clusterDefault:
  12. brokerClass: YourBroker
  13. namespaceDefaults:
  14. namespace1:
  15. brokerClass: MTChannelBasedBroker
  16. namespace2:
  17. brokerClass: MTChannelBasedBroker

Changing the default configuration of the Broker

Changing the default configuration for the cluster

You can also control Broker configuration defaulting behaviour by specifying what gets defaulted into a broker.spec.config if left empty when being created.

If you have installed a different Channel implementation (for example Kafka), and by default would like to use that for any Broker created you could change the ConfigMap to look like this:

  1. apiVersion: v1
  2. kind: ConfigMap
  3. metadata:
  4. name: config-br-defaults
  5. namespace: knative-eventing
  6. labels:
  7. eventing.knative.dev/release: devel
  8. data:
  9. # Configuration for defaulting channels that do not specify CRD implementations.
  10. default-br-config: |
  11. clusterDefault:
  12. brokerClass: MTChannelBasedBroker
  13. apiVersion: v1
  14. kind: ConfigMap
  15. name: config-kafka-channel
  16. namespace: knative-eventing

Now every Broker created in the cluster without spec.config will be configured to use config-kafka-channel ConfigMap. Note that you can always still explicitly specify a different configuration for any given Broker by specifying it in the spec.config.

Changing the default configuration for namespaces

As mentioned, you can also control the defaulting behaviour for some set of namespaces. So, if for example, you wanted to use config-kafka-channel for all the other Brokers created, but wanted to use config-br-default-channel config the following namespaces: namespace3 and namespace4. You would modify the ConfigMap like this:

  1. apiVersion: v1
  2. kind: ConfigMap
  3. metadata:
  4. name: config-br-defaults
  5. namespace: knative-eventing
  6. labels:
  7. eventing.knative.dev/release: devel
  8. data:
  9. # Configuration for defaulting channels that do not specify CRD implementations.
  10. default-br-config: |
  11. clusterDefault:
  12. brokerClass: MTChannelBasedBroker
  13. apiVersion: v1
  14. kind: ConfigMap
  15. name: config-kafka-channel
  16. namespace: knative-eventing
  17. namespaceDefaults:
  18. namespace3:
  19. apiVersion: v1
  20. kind: ConfigMap
  21. name: config-br-default-channel
  22. namespace: knative-eventing
  23. namespace4:
  24. apiVersion: v1
  25. kind: ConfigMap
  26. name: config-br-default-channel
  27. namespace: knative-eventing

Note that we do not override the brokerClass for these namespaces. The brokerClass and config are independently configurable.