Configure Channels for Apache Kafka

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 YAML file for the kafka-channel ConfigMap using the following template:

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

    Note

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

  2. Apply the YAML file by running the command:

    1. kubectl apply -f <filename>.yaml

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

  3. Optional. To create a Broker that uses Kafka Channels, specify the kafka-channel ConfigMap in the Broker spec. You can do this by creating a YAML file using the following template:

    1. apiVersion: eventing.knative.dev/v1
    2. kind: Broker
    3. metadata:
    4. annotations:
    5. eventing.knative.dev/broker.class: MTChannelBasedBroker
    6. name: kafka-backed-broker
    7. namespace: default
    8. spec:
    9. config:
    10. apiVersion: v1
    11. kind: ConfigMap
    12. name: kafka-channel
    13. namespace: knative-eventing
  4. Apply the YAML file by running the command:

    1. kubectl apply -f <filename>.yaml

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

Enable/configure autoscaling of KafkaChannel dispatchers

To enable autoscaling of the KafkaChannel dispatcher you can read the instructions here