Last active
August 29, 2022 13:30
-
-
Save ram-pi/94439052a042ab9cb18053565664697e to your computer and use it in GitHub Desktop.
Kafka Cluster with 3 brokers and 1 Zookeeper
This file contains 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
version: '3.8' | |
services: | |
# ZOOKEEPER | |
zookeeper: | |
container_name: "zookeeper" | |
image: confluentinc/cp-zookeeper:${CF_TAG} | |
environment: | |
ZOOKEEPER_CLIENT_PORT: 2181 | |
ZOOKEEPER_TICK_TIME: 2000 | |
# ENABLE 4LW COMMANDS FROM EVERYWHERE | |
# ZOOKEEPER JMX MONITORING | |
KAFKA_JMX_PORT: 40001 | |
KAFKA_JMX_HOSTNAME: localhost | |
# ENABLE SASL | |
KAFKA_OPTS: "-Dzookeeper.4lw.commands.whitelist=*" | |
ports: | |
- 2181:2181 | |
- 40001:40001 | |
cap_add: | |
- NET_ADMIN | |
# KAFKA BROKER 1 | |
kafka-1: | |
container_name: "kafka-1" | |
image: confluentinc/cp-server:${CF_TAG} | |
hostname: kafka-1 | |
depends_on: | |
- zookeeper | |
# KAFKA SECURITY CONFIGURATION | |
environment: | |
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181" | |
KAFKA_LISTENERS: "INTERNAL://:9092, EXTERNAL://:19092" | |
KAFKA_ADVERTISED_LISTENERS: "INTERNAL://kafka-1:9092, EXTERNAL://localhost:19092" | |
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "INTERNAL:PLAINTEXT, EXTERNAL:PLAINTEXT" | |
KAFKA_INTER_BROKER_LISTENER_NAME: "INTERNAL" | |
# KAFKA BROKER ID | |
KAFKA_BROKER_ID: "1" | |
# KAFKA GENERAL CONFIGURATION | |
KAFKA_DELETE_TOPIC_ENABLE: "true" | |
# KAFKA JMX MONITORING | |
#KAFKA_OPTS: "-Djava.security.auth.login.config=/etc/kafka/kafka.sasl.jaas.conf" | |
ports: | |
- 19092:19092 | |
cap_add: | |
- NET_ADMIN | |
# KAFKA BROKER 2 | |
kafka-2: | |
container_name: "kafka-2" | |
image: confluentinc/cp-server:${CF_TAG} | |
hostname: kafka-2 | |
depends_on: | |
- zookeeper | |
# KAFKA SECURITY CONFIGURATION | |
environment: | |
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181" | |
KAFKA_LISTENERS: "INTERNAL://:9092, EXTERNAL://:29092" | |
KAFKA_ADVERTISED_LISTENERS: "INTERNAL://kafka-2:9092, EXTERNAL://localhost:29092" | |
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "INTERNAL:PLAINTEXT, EXTERNAL:PLAINTEXT" | |
KAFKA_INTER_BROKER_LISTENER_NAME: "INTERNAL" | |
# KAFKA BROKER ID | |
KAFKA_BROKER_ID: "2" | |
# KAFKA GENERAL CONFIGURATION | |
KAFKA_DELETE_TOPIC_ENABLE: "true" | |
# KAFKA JMX MONITORING | |
#KAFKA_OPTS: "-Djava.security.auth.login.config=/etc/kafka/kafka.sasl.jaas.conf" | |
ports: | |
- 29092:29092 | |
cap_add: | |
- NET_ADMIN | |
# KAFKA BROKER 3 | |
kafka-3: | |
container_name: "kafka-3" | |
image: confluentinc/cp-server:${CF_TAG} | |
hostname: kafka-3 | |
depends_on: | |
- zookeeper | |
# KAFKA SECURITY CONFIGURATION | |
environment: | |
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181" | |
KAFKA_LISTENERS: "INTERNAL://:9092, EXTERNAL://:39092" | |
KAFKA_ADVERTISED_LISTENERS: "INTERNAL://kafka-3:9092, EXTERNAL://localhost:39092" | |
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "INTERNAL:PLAINTEXT, EXTERNAL:PLAINTEXT" | |
KAFKA_INTER_BROKER_LISTENER_NAME: "INTERNAL" | |
# KAFKA BROKER ID | |
KAFKA_BROKER_ID: "3" | |
# KAFKA GENERAL CONFIGURATION | |
KAFKA_DELETE_TOPIC_ENABLE: "true" | |
# KAFKA JMX MONITORING | |
#KAFKA_OPTS: "-Djava.security.auth.login.config=/etc/kafka/kafka.sasl.jaas.conf" | |
ports: | |
- 39092:39092 | |
cap_add: | |
- NET_ADMIN |
This file contains 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
CF_TAG="7.2.1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment