Skip to content

Instantly share code, notes, and snippets.

@Winand
Created June 21, 2022 09:15
Show Gist options
  • Save Winand/e6a9497e1411344127f66eae75a84e7e to your computer and use it in GitHub Desktop.
Save Winand/e6a9497e1411344127f66eae75a84e7e to your computer and use it in GitHub Desktop.
Пример: кластер Kafka
# https://dimosr.github.io/kafka-docker/
version: '3.4'
services:
zookeeper:
image: 'bitnami/zookeeper:3.8'
ports:
- '2181:2181'
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
kafka:
# Confluent | Kafka
# 7.1.1 | 3.1.0
# https://docs.confluent.io/platform/current/release-notes/index.html
image: 'confluentinc/cp-kafka:7.1.1'
depends_on:
- zookeeper
# hostname: kafka # Specified hostname will be visible in brokers list in kafka-ui
ports:
- "9092:9092"
environment:
# Uppercase, KAFKA_ prefix, replaces: "." > "_", "-" > "__", "_" > "___"
# https://docs.confluent.io/platform/current/installation/docker/config-reference.html#confluent-ak-configuration
# zookeeper.connect: ZooKeeper connection(s) string (hostname1:port1,hostname2:port2/chroot/path)
# https://kafka.apache.org/documentation/#brokerconfigs_zookeeper.connect
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
# listener.security.protocol.map: map between listener names and security protocols
# This must be defined for the same security protocol to be usable in more than one port or IP
# e.g. INTERNAL:SSL,EXTERNAL:SSL
# Default: PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
# https://kafka.apache.org/documentation/#brokerconfigs_listener.security.protocol.map
# In KRaft mode listener names (KRaft requires controller.listener.names!) are mapped to PLAINTEXT by default
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CLIENT:PLAINTEXT,INTER_BROKER:PLAINTEXT
# advertised.listeners: listeners to publish to ZooKeeper for clients to use,
# if different from the `listeners`
# https://kafka.apache.org/documentation/#brokerconfigs_advertised.listeners
# ! Kafka fails to start w/o `advertised.listeners` specified
KAFKA_ADVERTISED_LISTENERS: CLIENT://localhost:9092,INTER_BROKER://:8092
# Defines which listener to use for inter-broker communication.
# Kafka brokers communicate between themselves, usually on the internal network
# (!) If Kafka clients are not local to the broker’s network, additional listeners are required.
# Each listener will report the address where it can be reached.
# https://docs.confluent.io/platform/current/kafka/multi-node.html
KAFKA_INTER_BROKER_LISTENER_NAME: INTER_BROKER
# KAFKA_CLUSTER_ID: test-kafka-cluster
kafka-2:
image: 'confluentinc/cp-kafka:7.1.1'
depends_on:
- zookeeper
ports:
- "9093:9093"
environment:
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CLIENT:PLAINTEXT,INTER_BROKER:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: CLIENT://localhost:9093,INTER_BROKER://:8093
KAFKA_INTER_BROKER_LISTENER_NAME: INTER_BROKER
# KAFKA_CLUSTER_ID: test-kafka-cluster
kafka-3:
image: 'confluentinc/cp-kafka:7.1.1'
depends_on:
- zookeeper
ports:
- "9094:9094"
environment:
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CLIENT:PLAINTEXT,INTER_BROKER:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: CLIENT://localhost:9094,INTER_BROKER://:8094
KAFKA_INTER_BROKER_LISTENER_NAME: INTER_BROKER
# KAFKA_CLUSTER_ID: test-kafka-cluster
kafka-ui:
image: provectuslabs/kafka-ui
depends_on:
- kafka
ports:
- "8080:8080"
restart: "no"
environment:
- KAFKA_CLUSTERS_0_NAME=DEV
- KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka:8092
- KAFKA_CLUSTERS_0_ZOOKEEPER=zookeeper:2181
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment