Skip to content

Commit

Permalink
Adding Kafka docker-compose script for kraft
Browse files Browse the repository at this point in the history
  • Loading branch information
sobychacko committed Apr 30, 2024
1 parent 9cbd459 commit f230d87
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tools/kafka/docker-compose/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
=== Kafka Cluster
Runs a multi-node Kafka cluster w/ 3 brokers available at `locahost:9091,localhost:9092,localhost:9093`.

To start the brokers run the following command:
To start the brokers using zookeeper for leader election, run the following command:
[source,shell]
----
docker-compose -f ./kafka-cluster.yml up
Expand All @@ -17,6 +17,8 @@ docker-compose -f ./kafka-cluster.yml down

TIP: To start the containers in the foreground simply add `-d` to the start command. To stop containers that are running in the foreground simple issue `CTRL-C` command.

To start a single node Kafka cluster using the `kraft` protocol, use the `kraft.yml` file instead.

Running a quick test:

Now that we started our clusters, let us try to produce data to a topic on the cluster and then consume from it.
Expand Down
29 changes: 29 additions & 0 deletions tools/kafka/docker-compose/kraft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3'

services:

kafka:
image: apache/kafka:latest
container_name: kafka
hostname: kafka
ports:
- "9092:9092"
- "9101:9101"
environment:
KAFKA_NODE_ID: 1
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: 'CONTROLLER:PLAINTEXT,PLAINTEXT_DOCKER:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT'
KAFKA_LISTENERS: 'PLAINTEXT_DOCKER://kafka:29092,CONTROLLER://kafka:29093,PLAINTEXT_HOST://0.0.0.0:9092'
KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT_DOCKER://kafka:29092,PLAINTEXT_HOST://localhost:9092'
KAFKA_NUM_PARTITIONS: 10
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_JMX_PORT: 9101
KAFKA_JMX_HOSTNAME: localhost
KAFKA_PROCESS_ROLES: 'broker,controller'
KAFKA_CONTROLLER_QUORUM_VOTERS: '1@kafka:29093'
KAFKA_INTER_BROKER_LISTENER_NAME: 'PLAINTEXT_DOCKER'
KAFKA_CONTROLLER_LISTENER_NAMES: 'CONTROLLER'
KAFKA_LOG_DIRS: '/tmp/kraft-combined-logs'

0 comments on commit f230d87

Please sign in to comment.