Configure Kafka Channels

Note

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

To use Kafka Channels, you must:

  1. Install the KafkaChannel custom resource definition (CRD).
  2. Create a ConfigMap that specifies default configurations for how KafkaChannel instances are created.

Create a kafka-channel ConfigMap

  1. Create a kafka-channel ConfigMap by running the command:

    1. kubectl apply -f - <<EOF
    2. apiVersion: v1
    3. kind: ConfigMap
    4. metadata:
    5. name: kafka-channel
    6. namespace: knative-eventing
    7. data:
    8. channelTemplateSpec: |
    9. apiVersion: messaging.knative.dev/v1beta1
    10. kind: KafkaChannel
    11. spec:
    12. numPartitions: 3
    13. replicationFactor: 1
    14. EOF

    Note

    This example specifies two extra parameters that are specific to Kafka Channels; numPartitions and replicationFactor.

  2. Optional. To create a Broker that uses Kafka Channels, specify the kafka-channel ConfigMap in the Broker spec. You can do this by running the command:

    1. kubectl apply -f - <<EOF
    2. apiVersion: eventing.knative.dev/v1
    3. kind: Broker
    4. metadata:
    5. annotations:
    6. eventing.knative.dev/broker.class: MTChannelBasedBroker
    7. name: kafka-backed-broker
    8. namespace: default
    9. spec:
    10. config:
    11. apiVersion: v1
    12. kind: ConfigMap
    13. name: kafka-channel
    14. namespace: knative-eventing
    15. EOF