Skip to content

Instantly share code, notes, and snippets.

@naramdash
Last active July 10, 2023 01:46
Show Gist options
  • Save naramdash/c11ff9c81e9c6ec00bd2ca2f0c4157b2 to your computer and use it in GitHub Desktop.
Save naramdash/c11ff9c81e9c6ec00bd2ca2f0c4157b2 to your computer and use it in GitHub Desktop.
kafka kraft + docker compose minimum setting
services:
kafka-node-1:
container_name: kafka-node-1
image: confluentinc/cp-kafka:7.4.0
environment:
CLUSTER_ID: 'MkU3OEVBNTcwNTJENDM2Qk'
KAFKA_NODE_ID: 1
KAFKA_PROCESS_ROLES: 'broker,controller'
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: 'CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT'
KAFKA_LISTENERS: 'CONTROLLER://kafka-node-1:29093,PLAINTEXT://0.0.0.0:9092'
KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT://localhost:9092'
KAFKA_INTER_BROKER_LISTENER_NAME: 'PLAINTEXT'
KAFKA_CONTROLLER_LISTENER_NAMES: 'CONTROLLER'
KAFKA_CONTROLLER_QUORUM_VOTERS: '1@kafka-node-1:29093,2@kafka-node-2:29093,3@kafka-node-3:29093'
# ports:
# - "9092:9092"
# - "29093:29093"
expose:
- "9092"
- "29093"
volumes:
- type: volume
source: kafka-node-1-data
target: /var/lib/kafka
links:
- kafka-node-2
- kafka-node-3
kafka-node-2:
container_name: kafka-node-2
image: confluentinc/cp-kafka:7.4.0
environment:
CLUSTER_ID: 'MkU3OEVBNTcwNTJENDM2Qk'
KAFKA_NODE_ID: 2
KAFKA_PROCESS_ROLES: 'broker,controller'
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: 'CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT'
KAFKA_LISTENERS: 'CONTROLLER://kafka-node-2:29093,PLAINTEXT://0.0.0.0:9092'
KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT://localhost:9092'
KAFKA_INTER_BROKER_LISTENER_NAME: 'PLAINTEXT'
KAFKA_CONTROLLER_LISTENER_NAMES: 'CONTROLLER'
KAFKA_CONTROLLER_QUORUM_VOTERS: '1@kafka-node-1:29093,2@kafka-node-2:29093,3@kafka-node-3:29093'
# ports:
# - "9092:9092"
# - "29093:29093"
# links:
# - kafka-node-1
# - kafka-node-3
expose:
- "9092"
- "29093"
volumes:
- type: volume
source: kafka-node-2-data
target: /var/lib/kafka
kafka-node-3:
container_name: kafka-node-3
image: confluentinc/cp-kafka:7.4.0
environment:
CLUSTER_ID: 'MkU3OEVBNTcwNTJENDM2Qk'
KAFKA_NODE_ID: 3
KAFKA_PROCESS_ROLES: 'broker,controller'
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: 'CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT'
KAFKA_LISTENERS: 'CONTROLLER://kafka-node-3:29093,PLAINTEXT://0.0.0.0:9092'
KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT://localhost:9092'
KAFKA_INTER_BROKER_LISTENER_NAME: 'PLAINTEXT'
KAFKA_CONTROLLER_LISTENER_NAMES: 'CONTROLLER'
KAFKA_CONTROLLER_QUORUM_VOTERS: '1@kafka-node-1:29093,2@kafka-node-2:29093,3@kafka-node-3:29093'
# ports:
# - "9092:9092"
# - "29093:29093"
# links:
# - kafka-node-1
# - kafka-node-2
expose:
- "9092"
- "29093"
volumes:
- type: volume
source: kafka-node-3-data
target: /var/lib/kafka
volumes:
kafka-node-1-data:
kafka-node-2-data:
kafka-node-3-data:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment