Last active
April 23, 2024 20:44
-
-
Save enimiste/a29f87c8d09c9f6b4754a569e207ee22 to your computer and use it in GitHub Desktop.
Kafka cluster docker-compose config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This file contains two config and it can't be runned | |
| # You should keep only one config (Single node or HA version) | |
| # Single node | |
| version: '2' | |
| services: | |
| zookeeper: | |
| image: confluentinc/cp-zookeeper:7.4.4 | |
| environment: | |
| ZOOKEEPER_CLIENT_PORT: 2181 | |
| ZOOKEEPER_TICK_TIME: 2000 | |
| ports: | |
| - 22181:2181 | |
| kafka: | |
| image: confluentinc/cp-kafka:7.4.4 | |
| depends_on: | |
| - zookeeper | |
| ports: | |
| - 29092:29092 | |
| environment: | |
| KAFKA_BROKER_ID: 1 | |
| KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 | |
| KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092 | |
| KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT | |
| KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT | |
| KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 | |
| # HA Cluster (redundancy) | |
| version: '2' | |
| services: | |
| zookeeper-1: | |
| image: confluentinc/cp-zookeeper:7.4.4 | |
| environment: | |
| ZOOKEEPER_CLIENT_PORT: 2181 | |
| ZOOKEEPER_TICK_TIME: 2000 | |
| ports: | |
| - 22181:2181 | |
| zookeeper-2: | |
| image: confluentinc/cp-zookeeper:7.4.4 | |
| environment: | |
| ZOOKEEPER_CLIENT_PORT: 2181 | |
| ZOOKEEPER_TICK_TIME: 2000 | |
| ports: | |
| - 32181:2181 | |
| kafka-1: | |
| image: confluentinc/cp-kafka:7.4.4 | |
| depends_on: | |
| - zookeeper-1 | |
| - zookeeper-2 | |
| ports: | |
| - 29092:29092 | |
| environment: | |
| KAFKA_BROKER_ID: 1 | |
| KAFKA_ZOOKEEPER_CONNECT: zookeeper-1:2181,zookeeper-2:2181 | |
| KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka-1:9092,PLAINTEXT_HOST://localhost:29092 | |
| KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT | |
| KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT | |
| KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 | |
| kafka-2: | |
| image: confluentinc/cp-kafka:7.4.4 | |
| depends_on: | |
| - zookeeper-1 | |
| - zookeeper-2 | |
| ports: | |
| - 39092:39092 | |
| environment: | |
| KAFKA_BROKER_ID: 2 | |
| KAFKA_ZOOKEEPER_CONNECT: zookeeper-1:2181,zookeeper-2:2181 | |
| KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka-2:9092,PLAINTEXT_HOST://localhost:39092 | |
| KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT | |
| KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT | |
| KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 | |
| # docker exec -it container-name-here bash | |
| # > kafka-topics --list --bootstrap-server=localhost:29092 | |
| # > kafka-console-consumer --bootstrap-server=localhost:29092 --topic topic-name-here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment