ConfigMaps

Knative Eventing provides a config-br-defaults ConfigMap that contains the configuration settings that govern default broker creation.

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

  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

Channel implementation options

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 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: kafka-channel
  16. 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.

For more information about creating a kafka-channel ConfigMap to use with your broker, see the Kafka Channel ConfigMap documentation.

Changing the default channel implementation for a namespace

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:

  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. namespace-1:
  19. apiVersion: v1
  20. kind: ConfigMap
  21. name: config-br-default-channel
  22. namespace: knative-eventing
  23. namespace-2:
  24. apiVersion: v1
  25. kind: ConfigMap
  26. name: config-br-default-channel
  27. namespace: knative-eventing

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

Configuring the broker class

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:

    1. apiVersion: eventing.knative.dev/v1
    2. kind: Broker
    3. metadata:
    4. annotations:
    5. eventing.knative.dev/broker.class: MTChannelBasedBroker
    6. name: default
    7. namespace: default
  2. Configure the spec.config with the details of the ConfigMap that defines the backing channel for the broker class:

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

Configuring the default BrokerClass for the cluster

​ 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. # Configuration for defaulting channels that do not specify CRD implementations.
  10. default-br-config: |
  11. clusterDefault:
  12. brokerClass: MTChannelBasedBroker

Configuring the default BrokerClass for namespaces

​ You can modify the default broker class for one or more namespaces.

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: ​

  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: KafkaBroker
  13. namespaceDefaults:
  14. namespace1:
  15. brokerClass: MTChannelBasedBroker
  16. namespace2:
  17. brokerClass: MTChannelBasedBroker