Documentation Index
Fetch the complete documentation index at: https://docs.ahmadraza.in/llms.txt
Use this file to discover all available pages before exploring further.
๐ณ Kafka KRaft (Raft-based) Setup with Docker Compose ๐ณ
This guide demonstrates how to set up a KRaft-based Apache Kafka broker (no Zookeeper needed!) along with Kafka UI for topic/consumer inspection.๐ฆ Docker Compose: Kafka KRaft + Kafka UI
๐ Key Kafka KRaft Config Explanation
| Variable | Description |
|---|---|
KAFKA_PROCESS_ROLES | Enables both broker and controller in single node (Raft mode). |
KAFKA_LISTENERS | Declares three listener endpoints: PLAINTEXT, CONTROLLER, and external client EXTERNAL. |
KAFKA_ADVERTISED_LISTENERS | Makes Kafka reachable from other containers (broker:9092) and host system (localhost:9094). |
KAFKA_CONTROLLER_QUORUM_VOTERS | Defines Raft controller quorum (use format: <node_id>@<host>:<port>). |
KAFKA_CONTROLLER_LISTENER_NAMES | Identifies which listener handles controller communication (Raft). |
KAFKA_TRANSACTION_STATE_LOG_* | Required even for a single-broker Kafka with transactions enabled. |
๐ Usage Commands
๐ข Start the Kafka Cluster
Kafka will be exposed on:
localhost:9094โ External client accesslocalhost:8088โ Kafka UI Dashboard
๐ด Stop and Clean Up
๐งช Working with Kafka Topics (No Zookeeper)
โ Create Topics
๐ List Topics
๐ฅ Consume from a Topic
๐ค Produce to a Topic
๐ Kafka UI Dashboard
Access the Kafka dashboard at: ๐ http://localhost:8088You can:
- View topics
- Inspect partitions and messages
- See consumer groups
- Produce/consume messages directly from UI
โ ๏ธ Notes
- No Zookeeper: This setup uses Kafka KRaft mode, available from Apache Kafka 3.x+, eliminating Zookeeper dependency.
- Multiple Brokers: For multi-node Raft quorum, adjust
KAFKA_CONTROLLER_QUORUM_VOTERSaccordingly. - Production Security: Add SSL and authentication configs before exposing Kafka publicly.
๐ Summary
| Action | Command |
|---|---|
| Start Cluster | docker-compose up -d |
| Stop Cluster | docker-compose down |
| Create Topic | kafka-topics.sh --create ... |
| List Topics | kafka-topics.sh --list ... |
| Consume Logs | kafka-console-consumer.sh --topic ... |
| Kafka Dashboard UI | http://localhost:8088 |
