Skip to content

Instantly share code, notes, and snippets.

@kdhfred
Last active November 17, 2023 08:48
Show Gist options
  • Save kdhfred/9b6f0c32f93542f625e157f17b60813c to your computer and use it in GitHub Desktop.
Save kdhfred/9b6f0c32f93542f625e157f17b60813c to your computer and use it in GitHub Desktop.
Multi zookeepers and Multi kafka clusters
sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required username="user" password="password";
security.protocol=SASL_PLAINTEXT
sasl.mechanism=SCRAM-SHA-256
version: '3.8'
services:
zookeeper-1:
image: bitnami/zookeeper:latest
environment:
ZOO_SERVER_ID: 1
ZOO_TICK_TIME: 2000
ZOO_INIT_LIMIT: 5
ZOO_SYNC_LIMIT: 2
ZOO_SERVERS: zookeeper-1:2888:3888;zookeeper-2:2888:3888;zookeeper-3:2888:3888
ZOO_LOG_LEVEL: DEBUG
ALLOW_ANONYMOUS_LOGIN: "yes"
ports:
- "22181:2181"
- "22888:2888"
- "23888:3888"
zookeeper-2:
image: bitnami/zookeeper:latest
environment:
ZOO_SERVER_ID: 2
ZOO_TICK_TIME: 2000
ZOO_INIT_LIMIT: 5
ZOO_SYNC_LIMIT: 2
ZOO_SERVERS: zookeeper-1:2888:3888;zookeeper-2:2888:3888;zookeeper-3:2888:3888
ALLOW_ANONYMOUS_LOGIN: "yes"
ports:
- "32181:2181"
- "32888:2888"
- "33888:3888"
zookeeper-3:
image: bitnami/zookeeper:latest
environment:
ZOO_SERVER_ID: 3
ZOO_TICK_TIME: 2000
ZOO_INIT_LIMIT: 5
ZOO_SYNC_LIMIT: 2
ZOO_SERVERS: zookeeper-1:2888:3888;zookeeper-2:2888:3888;zookeeper-3:2888:3888
ALLOW_ANONYMOUS_LOGIN: "yes"
ports:
- "42181:2181"
- "42888:2888"
- "43888:3888"
kafka-1:
image: bitnami/kafka:latest
depends_on:
- zookeeper-1
- zookeeper-2
- zookeeper-3
volumes:
- ./kafka/admin.properties:/opt/bitnami/kafka/config/admin.properties:ro
- ./kafka/feed.properties:/opt/bitnami/kafka/config/feed.properties:ro
ports:
- 29092:9092
environment:
KAFKA_CFG_NODE_ID: 1
KAFKA_ZOOKEEPER_PROTOCOL: PLAINTEXT
KAFKA_CFG_ZOOKEEPER_CONNECT: zookeeper-1:2181,zookeeper-2:2181,zookeeper-3:2181
KAFKA_CFG_SASL_ENABLED_MECHANISMS: SCRAM-SHA-256
KAFKA_CFG_SASL_MECHANISM_INTER_BROKER_PROTOCOL: SCRAM-SHA-256
KAFKA_CFG_LISTENERS: SASL_PLAINTEXT://kafka-1:9092
KAFKA_CFG_ADVERTISED_LISTENERS: SASL_PLAINTEXT://kafka-1:9092
KAFKA_CFG_INTER_BROKER_LISTENER_NAME: SASL_PLAINTEXT
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: SASL_PLAINTEXT:SASL_PLAINTEXT
KAFKA_CLIENT_USERS: user
KAFKA_CLIENT_PASSWORDS: password
KAFKA_INTER_BROKER_USER: kafka-broker
KAFKA_INTER_BROKER_PASSWORD: password
KAFKA_CFG_AUTHORIZER_CLASS_NAME: kafka.security.authorizer.AclAuthorizer
KAFKA_CFG_SUPER_USERS: User:user;User:kafka-broker
kafka-2:
image: bitnami/kafka:latest
depends_on:
- zookeeper-1
- zookeeper-2
- zookeeper-3
volumes:
- ./kafka/admin.properties:/opt/bitnami/kafka/config/admin.properties:ro
ports:
- "39092:9092"
environment:
KAFKA_CFG_NODE_ID: 2
KAFKA_ZOOKEEPER_PROTOCOL: PLAINTEXT
KAFKA_CFG_ZOOKEEPER_CONNECT: zookeeper-1:2181,zookeeper-2:2181,zookeeper-3:2181
KAFKA_CFG_SASL_ENABLED_MECHANISMS: SCRAM-SHA-256
KAFKA_CFG_SASL_MECHANISM_INTER_BROKER_PROTOCOL: SCRAM-SHA-256
KAFKA_CFG_LISTENERS: SASL_PLAINTEXT://kafka-2:9092
KAFKA_CFG_ADVERTISED_LISTENERS: SASL_PLAINTEXT://kafka-2:9092
KAFKA_CFG_INTER_BROKER_LISTENER_NAME: SASL_PLAINTEXT
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: SASL_PLAINTEXT:SASL_PLAINTEXT
KAFKA_CLIENT_USERS: user
KAFKA_CLIENT_PASSWORDS: password
KAFKA_INTER_BROKER_USER: kafka-broker
KAFKA_INTER_BROKER_PASSWORD: password
KAFKA_CFG_AUTHORIZER_CLASSNAME: kafka.security.authorizer.AclAuthorizer
KAFKA_CFG_SUPER_USERS: User:user;User:kafka-broker
kafka-3:
image: bitnami/kafka:latest
depends_on:
- zookeeper-1
- zookeeper-2
- zookeeper-3
volumes:
- ./kafka/admin.properties:/opt/bitnami/kafka/config/admin.properties:ro
ports:
- "49092:9092"
environment:
KAFKA_CFG_NODE_ID: 3
KAFKA_ZOOKEEPER_PROTOCOL: PLAINTEXT
KAFKA_CFG_ZOOKEEPER_CONNECT: zookeeper-1:2181,zookeeper-2:2181,zookeeper-3:2181
KAFKA_CFG_SASL_ENABLED_MECHANISMS: SCRAM-SHA-256
KAFKA_CFG_SASL_MECHANISM_INTER_BROKER_PROTOCOL: SCRAM-SHA-256
KAFKA_CFG_LISTENERS: SASL_PLAINTEXT://kafka-3:9092
KAFKA_CFG_ADVERTISED_LISTENERS: SASL_PLAINTEXT://kafka-3:9092
KAFKA_CFG_INTER_BROKER_LISTENER_NAME: SASL_PLAINTEXT
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: SASL_PLAINTEXT:SASL_PLAINTEXT
KAFKA_CLIENT_USERS: user
KAFKA_CLIENT_PASSWORDS: password
KAFKA_INTER_BROKER_USER: kafka-broker
KAFKA_INTER_BROKER_PASSWORD: password
KAFKA_CFG_AUTHORIZER_CLASS_NAME: kafka.security.authorizer.AclAuthorizer
KAFKA_CFG_SUPER_USERS: User:user;User:kafka-broker
kafka-ui:
image: provectuslabs/kafka-ui:latest
ports:
- "9090:8080"
environment:
KAFKA_CLUSTERS_0_NAME: local
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka-1:9092,kafka-2:9092,kafka-3:9092
KAFKA_CLUSTERS_0_PROPERTIES_SECURITY_PROTOCOL: SASL_PLAINTEXT
KAFKA_CLUSTERS_0_PROPERTIES_SASL_MECHANISM: SCRAM-SHA-256
KAFKA_CLUSTERS_0_PROPERTIES_SASL_JAAS_CONFIG: org.apache.kafka.common.security.scram.ScramLoginModule required username="user" password="password";
KAFKA_CLUSTERS_0_PROPERTIES_PROTOCOL: SASL
depends_on:
- kafka-1
- kafka-2
- kafka-3
sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required username="feed" password="password";
security.protocol=SASL_PLAINTEXT
sasl.mechanism=SCRAM-SHA-256
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment