Configure Broker defaults

    The default config-br-defaults ConfigMap is as follows:

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

    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

    A Broker object that does not have a spec.config specified uses the config-br-default-channel ConfigMap dy default because this is specified in the config-br-defaults ConfigMap.

    However, if you have installed a different Channel implementation, for example, Kafka, and would like this to be used as the default Channel implementation for any Broker that is created, you can change the config-br-defaults ConfigMap to look as follows:

    1. apiVersion: v1
    2. kind: ConfigMap
    3. metadata:
    4. namespace: knative-eventing
    5. labels:
    6. eventing.knative.dev/release: devel
    7. data:
    8. # Configures the default for any Broker that does not specify a spec.config or Broker class.
    9. default-br-config: |
    10. brokerClass: MTChannelBasedBroker
    11. apiVersion: v1
    12. kind: ConfigMap
    13. name: kafka-channel
    14. namespace: knative-eventing

    Now every Broker created in the cluster that does not have a spec.config will be configured to use the kafka-channel ConfigMap.

    You can modify the default Broker creation behavior for one or more namespaces.

    For example, if you wanted to use the kafka-channel ConfigMap for all other Brokers created, but wanted to use config-br-default-channel ConfigMap for namespace-1 and namespace-2, you would use the following ConfigMap settings:

    Broker class options

    When a Broker is created without a specified BrokerClass annotation, the default MTChannelBasedBroker Broker class is used, as specified in the config-br-defaults ConfigMap.

    The following example creates a Broker called default in the default namespace, and uses MTChannelBasedBroker as the implementation:

    1. Create a YAML file for your Broker using the following example:

      1. apiVersion: eventing.knative.dev/v1
      2. kind: Broker
      3. metadata:
      4. name: default
      5. namespace: default
      1. kubectl apply -f <filename>.yaml

      Where <filename> is the name of the file you created in the previous step.

    To configure a Broker class, you can modify the eventing.knative.dev/broker.class annotation and spec.config for the Broker object. MTChannelBasedBroker is the Broker class default.

    1. Modify the eventing.knative.dev/broker.class annotation. Replace MTChannelBasedBroker with the class type you want to use:

    2. Configure the spec.config with the details of the ConfigMap that defines the backing Channel for the Broker class:

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

    You can configure the clusterDefault Broker class so that any Broker created in the cluster that does not have a BrokerClass annotation uses this default class.

    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. # Configures the default for any Broker that does not specify a spec.config or Broker class.
    10. default-br-config: |
    11. clusterDefault:
    12. brokerClass: MTChannelBasedBroker

    For example, if you want to use a KafkaBroker class for all other Brokers created on the cluster, but you want to use the MTChannelBasedBroker class for Brokers created in namespace-1 and namespace-2, you would use the following ConfigMap settings: