Skip to content

Commit 14a4bfc

Browse files
authored
Add Address Resolver (#61)
* Add AddressResolver to handle load-balancers configuration * add AddressResolver TLS example
1 parent b04b01a commit 14a4bfc

28 files changed

+451
-171
lines changed

.github/workflows/test_and_publish_image.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS: "-rabbitmq_stream advertised_host localhost"
1414
ports:
1515
- 5552:5552
16+
- 15672:15672
1617
steps:
1718
- name: Set up Go
1819
uses: actions/setup-go@v2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ vet
2222
perfTest/
2323
.vagrant/
2424
local/
25+
tls-gen/

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,10 @@ rabbitmq-server:
5959
-e RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-rabbitmq_stream advertised_host localhost" \
6060
--pull always \
6161
pivotalrabbitmq/rabbitmq-stream
62+
63+
rabbitmq-ha-proxy:
64+
cd compose; rm -rf tls-gen;
65+
cd compose; git clone https://github.com/michaelklishin/tls-gen tls-gen; cd tls-gen/basic; make
66+
cd compose; docker build -t haproxy-rabbitmq-cluster .
67+
cd compose; docker-compose down
68+
cd compose; docker-compose up

comopose/conf/rabbitmq.conf

Lines changed: 0 additions & 6 deletions
This file was deleted.

compose/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tls-gen/
2+
.DS_Store

compose/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM haproxy
2+
3+
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg

compose/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
RabbitMQ cluster with HA proxy
2+
===
3+
4+
how to run:
5+
6+
```bash
7+
git clone git@github.com:rabbitmq/rabbitmq-stream-go-client.git .
8+
make rabbitmq-ha-proxy
9+
```
10+
11+
ports:
12+
```
13+
- localhost:5553 #standard stream port
14+
- localhost:5554 #TLS stream port
15+
- http://localhost:15673 #management port
16+
```
File renamed without changes.

compose/conf/rabbitmq.conf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cluster_formation.peer_discovery_backend = rabbit_peer_discovery_classic_config
2+
3+
cluster_formation.classic_config.nodes.1 = rabbit@node0
4+
cluster_formation.classic_config.nodes.2 = rabbit@node1
5+
cluster_formation.classic_config.nodes.3 = rabbit@node2
6+
loopback_users.guest = false
7+
8+
ssl_options.cacertfile = /certs/ca_certificate.pem
9+
ssl_options.certfile = /certs/server_certificate.pem
10+
ssl_options.keyfile = /certs/server_key.pem
11+
listeners.ssl.default = 5671
12+
stream.listeners.ssl.default = 5551
13+
ssl_options.verify = verify_peer
14+
ssl_options.fail_if_no_peer_cert = false

comopose/docker-compose.yml renamed to compose/docker-compose.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,57 @@ services:
33
rabbit_node0:
44
environment:
55
- RABBITMQ_ERLANG_COOKIE='secret_cookie'
6-
- RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=-rabbitmq_stream advertised_host localhost advertised_port 5552
6+
- RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=-rabbitmq_stream advertised_host node0
77
networks:
88
- back
99
hostname: node0
1010
image: pivotalrabbitmq/rabbitmq-stream
1111
ports:
12-
- "15672:15672"
13-
- "5552:5552"
12+
- "5561:5551"
13+
- "5562:5552"
1414
tty: true
1515
volumes:
1616
- ./conf/:/etc/rabbitmq/
17+
- "./tls-gen/basic/result/:/certs"
1718
rabbit_node1:
1819
environment:
1920
- RABBITMQ_ERLANG_COOKIE='secret_cookie'
20-
- RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=-rabbitmq_stream advertised_host localhost advertised_port 5553
21+
- RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=-rabbitmq_stream advertised_host node1
2122
networks:
2223
- back
2324
hostname: node1
24-
depends_on:
25-
- rabbit_node_0
2625
image: pivotalrabbitmq/rabbitmq-stream
2726
ports:
28-
- "15673:15672"
29-
- "5553:5552"
27+
- "5571:5551"
28+
- "5572:5552"
3029
tty: true
3130
volumes:
3231
- ./conf/:/etc/rabbitmq/
32+
- "./tls-gen/basic/result/:/certs"
3333
rabbit_node2:
3434
environment:
3535
- RABBITMQ_ERLANG_COOKIE='secret_cookie'
36-
- RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=-rabbitmq_stream advertised_host localhost advertised_port 5554
36+
- RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=-rabbitmq_stream advertised_host node2
3737
networks:
3838
- back
3939
hostname: node2
40-
depends_on:
41-
- rabbit_node_1
4240
image: pivotalrabbitmq/rabbitmq-stream
4341
ports:
44-
- "15674:15672"
45-
- "5554:5552"
42+
- "5581:5551"
43+
- "5582:5552"
4644
tty: true
4745
volumes:
4846
- ./conf/:/etc/rabbitmq/
49-
47+
- "./tls-gen/basic/result/:/certs"
48+
haproxy:
49+
image: haproxy-rabbitmq-cluster
50+
# container_name: haproxy
51+
hostname: haproxy
52+
ports:
53+
- "5553:5552"
54+
- "5554:5551"
55+
- "15673:15672"
56+
networks:
57+
- back
5058
networks:
5159
back:

0 commit comments

Comments
 (0)