-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.standalone
118 lines (93 loc) · 3.5 KB
/
Makefile.standalone
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
#!make
ARCH ?= $(shell arch)
.PHONY: pipy
pipy:
@if [ ! -f /usr/local/bin/pipy ]; then wget https://github.com/flomesh-io/pipy/releases/download/0.90.2-13/pipy-0.90.2-13-generic_linux-$(ARCH).tar.gz && tar zxf pipy-0.90.2-13-generic_linux-$(ARCH).tar.gz && cp usr/local/bin/pipy /usr/local/bin && rm -rf pipy-0.90.2-13-generic_linux-$(ARCH).tar.gz usr; fi
.PHONY: up-ep1
up-ep1:
# Configure load-balancer end-point ep1
@sudo ip netns add ep1
@sudo ip link add eflb0ep1 type veth peer name eep1flb0 netns ep1
@sudo ip link set eflb0ep1 mtu 9000 up
@sudo ip addr add 31.31.31.254/24 dev eflb0ep1
@sudo ip -n ep1 link set eep1flb0 mtu 7000 up
@sudo ip netns exec ep1 ifconfig eep1flb0 31.31.31.1/24 up
@sudo ip netns exec ep1 ip route add default via 31.31.31.254
@sudo ip netns exec ep1 ifconfig lo up
@sudo ip netns exec ep1 pipy -e "pipy().listen(8080).serveHTTP(new Message('Hi, I am from ep1.\n'))" 1>/dev/null 2>&1 &
@sleep 1
@ping 31.31.31.1 -c 1
@curl 31.31.31.1:8080
.PHONY: up-ep2
up-ep2:
# Configure load-balancer end-point ep2
@sudo ip netns add ep2
@sudo ip link add eflb0ep2 type veth peer name eep2flb0 netns ep2
@sudo ip link set eflb0ep2 mtu 9000 up
@sudo ip addr add 32.32.32.254/24 dev eflb0ep2
@sudo ip -n ep2 link set eep2flb0 mtu 7000 up
@sudo ip netns exec ep2 ifconfig eep2flb0 32.32.32.1/24 up
@sudo ip netns exec ep2 ip route add default via 32.32.32.254
@sudo ip netns exec ep2 ifconfig lo up
@sudo ip netns exec ep2 pipy -e "pipy().listen(8080).serveHTTP(new Message('Hi, I am from ep2.\n'))" 1>/dev/null 2>&1 &
@sleep 1
@ping 32.32.32.1 -c 1
@curl 32.32.32.1:8080
.PHONY: up-ep3
up-ep3:
# Configure load-balancer end-point ep3
@sudo ip netns add ep3
@sudo ip link add eflb0ep3 type veth peer name eep3flb0 netns ep3
@sudo ip link set eflb0ep3 mtu 9000 up
@sudo ip addr add 33.33.33.254/24 dev eflb0ep3
@sudo ip -n ep3 link set eep3flb0 mtu 7000 up
@sudo ip netns exec ep3 ifconfig eep3flb0 33.33.33.1/24 up
@sudo ip netns exec ep3 ip route add default via 33.33.33.254
@sudo ip netns exec ep3 ifconfig lo up
@sudo ip netns exec ep3 pipy -e "pipy().listen(8080).serveHTTP(new Message('Hi, I am from ep3.\n'))" 1>/dev/null 2>&1 &
@sleep 1
@ping 33.33.33.1 -c 1
@curl 33.33.33.1:8080
.PHONY: up-h1
up-h1:
# Configure load-balancer end-point h1
@sudo ip netns add h1
@sudo ip link add eflb0h1 type veth peer name eh1flb0 netns h1
@sudo ip link set eflb0h1 mtu 9000 up
@sudo ip addr add 10.10.10.254/24 dev eflb0h1
@sudo ip -n h1 link set eh1flb0 mtu 7000 up
@sudo ip netns exec h1 ifconfig eh1flb0 10.10.10.1/24 up
@sudo ip netns exec h1 ip route add default via 10.10.10.254
@sudo ip netns exec h1 ifconfig lo up
.PHONY: down-ep1
down-ep1:
@sudo ip l del dev eflb0ep1
@sudo ip netns delete ep1
.PHONY: down-ep2
down-ep2:
@sudo ip l del dev eflb0ep2
@sudo ip netns delete ep2
.PHONY: down-ep3
down-ep3:
@sudo ip link del dev eflb0ep3
@sudo ip netns delete ep3
.PHONY: down-h1
down-h1:
@sudo ip link del dev eflb0h1
@sudo ip netns delete h1
EP_TARGETS = ep1 ep2 ep3 h1
$(foreach target,$(EP_TARGETS),$(eval up-$(target): pipy))
UP_TARGETS = $(addprefix up-, $(EP_TARGETS))
DOWN_TARGETS = $(addprefix down-,$(EP_TARGETS))
.PHONY: test-up
test-up: $(UP_TARGETS)
.PHONY: test-down
test-down: $(DOWN_TARGETS)
.PHONY: test-apply-lb
test-apply-lb:
@bin/fsmxlbc create lb 20.20.20.1 --tcp=8080:8080 --endpoints=31.31.31.1:1,32.32.32.1:1,33.33.33.1:1
.PHONY: test
test:
@ip netns exec h1 curl 20.20.20.1:8080
@ip netns exec h1 curl 20.20.20.1:8080
@ip netns exec h1 curl 20.20.20.1:8080