baf0d31dc97af6520df169e7eb2cebd0fb476e13
[demos/kafka/training] / docker-compose.yml
1 version: '3.2'
2 services:
3   kafka-0:
4     image: bitnami/kafka:3.3.1
5     environment:
6       KAFKA_ENABLE_KRAFT: 'yes'
7       KAFKA_KRAFT_CLUSTER_ID: r7dMBY60T16TrNCGeXniLw
8       KAFKA_CFG_PROCESS_ROLES: controller
9       KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
10       KAFKA_CFG_LISTENERS: CONTROLLER://:9092
11       KAFKA_CFG_ADVERTISED_LISTENERS: " "
12       KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT
13       KAFKA_BROKER_ID: 0
14       KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@kafka-0:9092
15       ALLOW_PLAINTEXT_LISTENER: 'yes'
16       KAFKA_CFG_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
17       KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: "false"
18
19   kafka-1:
20     image: bitnami/kafka:3.3.1
21     environment:
22       KAFKA_ENABLE_KRAFT: 'yes'
23       KAFKA_KRAFT_CLUSTER_ID: r7dMBY60T16TrNCGeXniLw
24       KAFKA_CFG_PROCESS_ROLES: broker
25       KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
26       KAFKA_CFG_LISTENERS: BROKER://:9092, LOCALHOST://:9081
27       KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: BROKER:PLAINTEXT, CONTROLLER:PLAINTEXT, LOCALHOST:PLAINTEXT
28       KAFKA_CFG_ADVERTISED_LISTENERS: BROKER://kafka-1:9092, LOCALHOST://localhost:9081
29       KAFKA_BROKER_ID: 1
30       KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@kafka-0:9092
31       ALLOW_PLAINTEXT_LISTENER: 'yes'
32       KAFKA_CFG_INTER_BROKER_LISTENER_NAME: BROKER
33       KAFKA_CFG_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
34       KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: "false"
35     ports:
36       - 9081:9081
37     depends_on:
38       - kafka-0
39
40   kafka-2:
41     image: bitnami/kafka:3.3.1
42     environment:
43       KAFKA_ENABLE_KRAFT: 'yes'
44       KAFKA_KRAFT_CLUSTER_ID: r7dMBY60T16TrNCGeXniLw
45       KAFKA_CFG_PROCESS_ROLES: broker
46       KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
47       KAFKA_CFG_LISTENERS: BROKER://:9092, LOCALHOST://:9082
48       KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: BROKER:PLAINTEXT, CONTROLLER:PLAINTEXT, LOCALHOST:PLAINTEXT
49       KAFKA_CFG_ADVERTISED_LISTENERS: BROKER://kafka-2:9092, LOCALHOST://localhost:9082
50       KAFKA_BROKER_ID: 2
51       KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@kafka-0:9092
52       ALLOW_PLAINTEXT_LISTENER: 'yes'
53       KAFKA_CFG_INTER_BROKER_LISTENER_NAME: BROKER
54       KAFKA_CFG_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
55       KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: "false"
56     ports:
57       - 9092:9082
58       - 9082:9082
59     networks:
60       default:
61         aliases:
62           - kafka
63     depends_on:
64       - kafka-0
65
66   kafka-3:
67     image: bitnami/kafka:3.3.1
68     environment:
69       KAFKA_ENABLE_KRAFT: 'yes'
70       KAFKA_KRAFT_CLUSTER_ID: r7dMBY60T16TrNCGeXniLw
71       KAFKA_CFG_PROCESS_ROLES: broker
72       KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
73       KAFKA_CFG_LISTENERS: BROKER://:9092, LOCALHOST://:9083
74       KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: BROKER:PLAINTEXT, CONTROLLER:PLAINTEXT, LOCALHOST:PLAINTEXT
75       KAFKA_CFG_ADVERTISED_LISTENERS: BROKER://kafka-3:9092, LOCALHOST://localhost:9083
76       KAFKA_BROKER_ID: 3
77       KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@kafka-0:9092
78       ALLOW_PLAINTEXT_LISTENER: 'yes'
79       KAFKA_CFG_INTER_BROKER_LISTENER_NAME: BROKER
80       KAFKA_CFG_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
81       KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: "false"
82     ports:
83       - 9083:9083
84     depends_on:
85       - kafka-0
86
87
88   setup:
89     image: juplo/toolbox
90     command: >
91       bash -c "
92         kafka-topics --bootstrap-server kafka:9092 --delete --if-exists --topic test
93         kafka-topics --bootstrap-server kafka:9092 --create --topic test --partitions 2 --replication-factor 3 --config min.insync.replicas=2
94         kafka-topics --bootstrap-server kafka:9092 --describe --topic test
95       "
96     depends_on:
97       - kafka-1
98       - kafka-2
99       - kafka-3
100
101   cli:
102     image: juplo/toolbox
103     command: sleep infinity
104     depends_on:
105       - kafka-1
106       - kafka-2
107       - kafka-3
108
109   producer:
110     image: juplo/rest-producer:1.0-SNAPSHOT
111     ports:
112       - 8080:8080
113     environment:
114       server.port: 8080
115       producer.bootstrap-server: kafka:9092
116       producer.client-id: producer
117       producer.topic: test
118
119   producer-0:
120     image: juplo/rest-producer:1.0-SNAPSHOT
121     ports:
122       - 8000:8080
123     environment:
124       server.port: 8080
125       producer.bootstrap-server: kafka:9092
126       producer.client-id: producer-0
127       producer.topic: test
128       producer.partition: 0
129
130   producer-1:
131     image: juplo/rest-producer:1.0-SNAPSHOT
132     ports:
133       - 8001:8080
134     environment:
135       server.port: 8080
136       producer.bootstrap-server: kafka:9092
137       producer.client-id: producer-1
138       producer.topic: test
139       producer.partition: 1
140
141   consumer:
142     image: juplo/simple-consumer:1.0-SNAPSHOT
143     command: kafka:9092 test my-group consumer