Default Broker ConfigMap

    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.

    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

    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. kind: ConfigMap
    4. name: config-br-default-channel
    5. namespace: knative-eventing

    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 and would prefer that by default any Broker created uses YourBroker you could modify the ConfigMap to look like this:

    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.

    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

    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:

    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.

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

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