Apache Kafka

Detailed documentation on the Apache Kafka pubsub component

Setup Kafka

You can run Kafka locally using this Docker image. To run without Docker, see the getting started guide here.

To run Kafka on Kubernetes, you can use the Helm Chart.

Create a Dapr component

The next step is to create a Dapr component for Kafka.

Create the following YAML file named kafka.yaml:

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. namespace: <NAMESPACE>
  6. spec:
  7. type: pubsub.kafka
  8. version: v1
  9. metadata:
  10. # Kafka broker connection setting
  11. - name: brokers
  12. # Comma separated list of kafka brokers
  13. value: "dapr-kafka.dapr-tests.svc.cluster.local:9092"
  14. # Enable auth. Default is "false"
  15. - name: authRequired
  16. value: "false"
  17. # Only available is authRequired is set to true
  18. - name: saslUsername
  19. value: <username>
  20. # Only available is authRequired is set to true
  21. - name: saslPassword
  22. value: <password>

Warning

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

Apply the configuration

Visit this guide for instructions on configuring pub/sub components.

Related links

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