-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
201 lines (193 loc) · 6.09 KB
/
Copy pathdocker-compose.yml
File metadata and controls
201 lines (193 loc) · 6.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# Kafka Performance Testing - Local Development Environment
# This creates a 3-broker Kafka cluster for testing performance scenarios
#
# Usage:
# docker-compose up -d # Start the cluster
# docker-compose logs -f # View logs
# docker-compose down # Stop and remove
# docker-compose down -v # Stop and remove with volumes
services:
# Zookeeper for Kafka coordination
zookeeper:
image: confluentinc/cp-zookeeper:7.5.0
container_name: zookeeper
hostname: zookeeper
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
volumes:
- zookeeper-data:/var/lib/zookeeper/data
- zookeeper-logs:/var/lib/zookeeper/log
healthcheck:
test: ["CMD", "nc", "-z", "localhost", "2181"]
interval: 10s
timeout: 5s
retries: 5
networks:
- kafka-network
# Kafka Broker 1
kafka-broker-1:
image: confluentinc/cp-kafka:7.5.0
container_name: kafka-broker-1
hostname: kafka-broker-1
depends_on:
zookeeper:
condition: service_healthy
ports:
- "9092:9092"
- "29092:29092"
environment:
KAFKA_BROKER_ID: 0
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,EXTERNAL:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka-broker-1:29092,EXTERNAL://localhost:9092
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 3
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 2
KAFKA_DEFAULT_REPLICATION_FACTOR: 3
KAFKA_NUM_PARTITIONS: 12
KAFKA_LOG_RETENTION_HOURS: 24
KAFKA_LOG_SEGMENT_BYTES: 1073741824
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
KAFKA_JMX_PORT: 9999
KAFKA_JMX_HOSTNAME: kafka-broker-1
volumes:
- kafka-broker-1-data:/var/lib/kafka/data
healthcheck:
test: ["CMD", "kafka-broker-api-versions", "--bootstrap-server", "localhost:29092"]
interval: 10s
timeout: 10s
retries: 10
networks:
- kafka-network
# Kafka Broker 2
kafka-broker-2:
image: confluentinc/cp-kafka:7.5.0
container_name: kafka-broker-2
hostname: kafka-broker-2
depends_on:
zookeeper:
condition: service_healthy
ports:
- "9093:9093"
- "29093:29093"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,EXTERNAL:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka-broker-2:29093,EXTERNAL://localhost:9093
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 3
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 2
KAFKA_DEFAULT_REPLICATION_FACTOR: 3
KAFKA_NUM_PARTITIONS: 12
KAFKA_LOG_RETENTION_HOURS: 24
KAFKA_LOG_SEGMENT_BYTES: 1073741824
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
KAFKA_JMX_PORT: 9999
KAFKA_JMX_HOSTNAME: kafka-broker-2
volumes:
- kafka-broker-2-data:/var/lib/kafka/data
healthcheck:
test: ["CMD", "kafka-broker-api-versions", "--bootstrap-server", "localhost:29093"]
interval: 10s
timeout: 10s
retries: 10
networks:
- kafka-network
# Kafka Broker 3
kafka-broker-3:
image: confluentinc/cp-kafka:7.5.0
container_name: kafka-broker-3
hostname: kafka-broker-3
depends_on:
zookeeper:
condition: service_healthy
ports:
- "9094:9094"
- "29094:29094"
environment:
KAFKA_BROKER_ID: 2
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,EXTERNAL:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka-broker-3:29094,EXTERNAL://localhost:9094
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 3
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 2
KAFKA_DEFAULT_REPLICATION_FACTOR: 3
KAFKA_NUM_PARTITIONS: 12
KAFKA_LOG_RETENTION_HOURS: 24
KAFKA_LOG_SEGMENT_BYTES: 1073741824
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
KAFKA_JMX_PORT: 9999
KAFKA_JMX_HOSTNAME: kafka-broker-3
volumes:
- kafka-broker-3-data:/var/lib/kafka/data
healthcheck:
test: ["CMD", "kafka-broker-api-versions", "--bootstrap-server", "localhost:29094"]
interval: 10s
timeout: 10s
retries: 10
networks:
- kafka-network
# Performance Testing Container
# Runs the Ansible playbooks against the local Kafka cluster
perf-test:
build:
context: .
dockerfile: Dockerfile
container_name: kafka-perf-test
hostname: kafka-perf-test
depends_on:
kafka-broker-1:
condition: service_healthy
kafka-broker-2:
condition: service_healthy
kafka-broker-3:
condition: service_healthy
volumes:
- ./results:/app/results
- ./examples/inventory:/app/examples/inventory
- ./roles:/app/roles
- ./playbooks:/app/playbooks
- ./meta:/app/meta
- ./scripts:/app/scripts
- ./ansible.cfg:/app/ansible.cfg:ro
environment:
ANSIBLE_HOST_KEY_CHECKING: "False"
ANSIBLE_RETRY_FILES_ENABLED: "False"
networks:
- kafka-network
# Keep container running for interactive use
command: ["sleep", "infinity"]
# Kafka UI for monitoring (optional)
kafka-ui:
image: provectuslabs/kafka-ui:latest
container_name: kafka-ui
hostname: kafka-ui
depends_on:
- kafka-broker-1
- kafka-broker-2
- kafka-broker-3
ports:
- "8080:8080"
environment:
KAFKA_CLUSTERS_0_NAME: local
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka-broker-1:29092,kafka-broker-2:29093,kafka-broker-3:29094
KAFKA_CLUSTERS_0_ZOOKEEPER: zookeeper:2181
networks:
- kafka-network
volumes:
zookeeper-data:
zookeeper-logs:
kafka-broker-1-data:
kafka-broker-2-data:
kafka-broker-3-data:
networks:
kafka-network:
driver: bridge