forked from G-Corp/kafe
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (56 loc) · 2.05 KB
/
Makefile
File metadata and controls
70 lines (56 loc) · 2.05 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
HAS_ELIXIR=1
# NO_REGISTRY_UPDATE=1
include bu.mk
release: dist lint tag ## Tag and release to hex.pm
$(verbose) $(REBAR) hex publish
integ: ## Run integration tests
$(verbose) $(REBAR) ct
tests-all: tests integ
check-etchosts:
@grep kafka1 /etc/hosts >/dev/null || \
printf 'Please add the following line to your /etc/hosts:\n\
127.0.0.1 kafka1 kafka2 kafka3\n\
'
define one_kafka
kafka$(1):
image: confluentinc/cp-kafka:3.3.0-1
depends_on:
- zookeeper
environment:
KAFKA_BROKER_ID: $(1)
KAFKA_ADVERTISED_LISTENERS: plaintext://kafka$(1):919$(1)
KAFKA_ZOOKEEPER_CONNECT: zookeeper
KAFKA_MESSAGE_MAX_BYTES: 1000000
KAFKA_OFFSETS_TOPIC_NUM_PARTITIONS: 6
KAFKA_UNCLEAN_LEADER_ELECTION_ENABLE: "true"
stop_grace_period: 30s
ports:
- "919$(1):919$(1)"
endef
define docker_compose_yml_v1
version: "2"
services:
zookeeper:
image: confluentinc/cp-zookeeper:3.3.0-1
environment:
ZOOKEEPER_CLIENT_PORT: 2181
$(call one_kafka,1)
$(call one_kafka,2)
$(call one_kafka,3)
endef
docker-compose.yml: Makefile ## Create docker-compose.yml
$(call render_template,docker_compose_yml_v1,docker-compose.yml)
# Commands to create the topics, and force auto-creation of the __consumer_offsets topic
define topic_commands
kafka-topics --create --zookeeper zookeeper:2181 --replica-assignment 1 --topic testone
kafka-topics --create --zookeeper zookeeper:2181 --replica-assignment 1:2,2:1 --topic testtwo
kafka-topics --create --zookeeper zookeeper:2181 --replica-assignment 1:2:3,2:3:1,3:1:2 --topic testthree
kafka-console-consumer --bootstrap-server localhost:9191 --new-consumer --timeout-ms 1 --topic testone 2>/dev/null
endef
docker-start: docker-compose.yml docker-stop check-etchosts ## (Re)Start docker
$(verbose) docker-compose up -d
$(verbose) sleep 5 # give cluster time to startup
$(verbose) docker-compose exec kafka1 bash -ec '$(subst $(newline),&&,$(topic_commands))'
docker-stop: docker-compose.yml ## Stop docker
$(verbose) docker-compose kill
$(verbose) docker-compose rm -svf