Kafka binding spec

Detailed documentation on the kafka binding component

Setup Dapr component

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. namespace: <NAMESPACE>
  6. spec:
  7. type: bindings.kafka
  8. version: v1
  9. metadata:
  10. - name: topics # Optional. in use for input bindings
  11. value: topic1,topic2
  12. - name: brokers
  13. value: localhost:9092,localhost:9093
  14. - name: consumerGroup
  15. value: group1
  16. - name: publishTopic # Optional. in use for output bindings
  17. value: topic3
  18. - name: authRequired # Required. default: "true"
  19. value: "false"
  20. - name: saslUsername # Optional.
  21. value: "user"
  22. - name: saslPassword # Optional.
  23. value: "password"
  • topics is a comma separated string of topics for an input binding.
  • brokers is a comma separated string of kafka brokers.
  • consumerGroup is a kafka consumer group to listen on.
  • publishTopic is the topic to publish for an output binding.
  • authRequired determines whether to use SASL authentication or not.
  • saslUsername is the SASL username for authentication. Only used if authRequired is set to - "true".
  • saslPassword is the SASL password for authentication. Only used if authRequired is set to - "true".

Warning

The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described here.

Specifying a partition key

When invoking the Kafka binding, its possible to provide an optional partition key by using the metadata section in the request body.

The field name is partitionKey.

Example:

  1. curl -X POST http://localhost:3500/v1.0/bindings/myKafka \
  2. -H "Content-Type: application/json" \
  3. -d '{
  4. "data": {
  5. "message": "Hi"
  6. },
  7. "metadata": {
  8. "partitionKey": "key1"
  9. },
  10. "operation": "create"
  11. }'

Output Binding Supported Operations

  • create

Related links

Last modified February 16, 2021: Merge pull request #1235 from dapr/update-v0.11 (b4e9fbb)