Skip to content

Commit e38bae4

Browse files
committed
add-ha-rabbit
1 parent 4b4e1f7 commit e38bae4

File tree

5 files changed

+110
-0
lines changed

5 files changed

+110
-0
lines changed

services/rabbit/Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
REPO_BASE_DIR := $(shell git rev-parse --show-toplevel)
2+
3+
include ${REPO_BASE_DIR}/scripts/common-services.Makefile
4+
# common-services.Makefile should be included first as common.Makefile
5+
#relies on STACK_NAME var which is defined in common-services.Makefile
6+
include ${REPO_BASE_DIR}/scripts/common.Makefile
7+
8+
.PHONY: up
9+
up: ${TEMP_COMPOSE} prune-docker-stack-configs ## Deploys metabase stack
10+
@docker stack deploy --with-registry-auth --prune --compose-file ${TEMP_COMPOSE} ${STACK_NAME}
11+
12+
up-aws: up
13+
14+
up-master: up
15+
16+
up-dalco: up
17+
18+
up-local: up
19+
20+
up-public: up
21+
22+
${TEMP_COMPOSE}: docker-compose.yml .env
23+
@${REPO_BASE_DIR}/scripts/docker-stack-config.bash -e .env $< > $@
24+
25+
docker-compose.yml: docker-compose.yml.j2 .env venv
26+
@$(call jinja, $<, .env, $@)

services/rabbit/README.md

Whitespace-only changes.

services/rabbit/docker-compose.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
services:
2+
rabbit01:
3+
image: itisfoundation/rabbitmq:4.1.2-management
4+
init: true
5+
# https://docs.docker.com/reference/cli/docker/service/create/#create-services-using-templates
6+
hostname: "{{.Service.Name}}"
7+
environment:
8+
RABBITMQ_DEFAULT_USER: ${RABBIT_USER}
9+
RABBITMQ_DEFAULT_PASS: ${RABBIT_PASSWORD}
10+
RABBITMQ_NODENAME: "rabbit@{{.Service.Name}}"
11+
volumes:
12+
- rabbit_data:/var/lib/rabbitmq
13+
# TODO: sync with existing rabbit attached networks
14+
networks:
15+
- rabbit
16+
# TODO: consider another healthcheck (e.g. check kubernetes operator)
17+
healthcheck:
18+
# see https://www.rabbitmq.com/monitoring.html#individual-checks for info about health-checks available in rabbitmq
19+
test: rabbitmq-diagnostics -q status
20+
interval: 5s
21+
timeout: 30s
22+
retries: 5
23+
start_period: 5s
24+
25+
busybox:
26+
image: ubuntu:22.04
27+
command: /bin/sh -c "sleep infinity"
28+
networks:
29+
- rabbit
30+
networks:
31+
# TODO: consider creating it externally for better control over subnets size and ip ranges
32+
rabbit:
33+
name: ${RABBIT_DOCKER_SWARM_NETWORK_NAME}
34+
driver: overlay
35+
attachable: true
36+
37+
volumes:
38+
rabbit_data:
39+
name: ${STACK_NAME}_rabbit_data
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
services:
2+
rabbit01:
3+
image: itisfoundation/rabbitmq:4.1.2-management
4+
init: true
5+
# https://docs.docker.com/reference/cli/docker/service/create/#create-services-using-templates
6+
hostname: {% raw %}"{{.Service.Name}}"{% endraw %}
7+
environment:
8+
RABBITMQ_DEFAULT_USER: ${RABBIT_USER}
9+
RABBITMQ_DEFAULT_PASS: ${RABBIT_PASSWORD}
10+
RABBITMQ_NODENAME: {% raw %}"rabbit@{{.Service.Name}}"{% endraw %}
11+
volumes:
12+
- rabbit_data:/var/lib/rabbitmq
13+
# TODO: sync with existing rabbit attached networks
14+
networks:
15+
- rabbit
16+
# TODO: consider another healthcheck (e.g. check kubernetes operator)
17+
healthcheck:
18+
# see https://www.rabbitmq.com/monitoring.html#individual-checks for info about health-checks available in rabbitmq
19+
test: rabbitmq-diagnostics -q status
20+
interval: 5s
21+
timeout: 30s
22+
retries: 5
23+
start_period: 5s
24+
25+
busybox:
26+
image: ubuntu:22.04
27+
command: /bin/sh -c "sleep infinity"
28+
networks:
29+
- rabbit
30+
networks:
31+
# TODO: consider creating it externally for better control over subnets size and ip ranges
32+
rabbit:
33+
name: ${RABBIT_DOCKER_SWARM_NETWORK_NAME}
34+
driver: overlay
35+
attachable: true
36+
37+
volumes:
38+
rabbit_data:
39+
name: ${STACK_NAME}_rabbit_data

services/rabbit/template.env

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
STACK_NAME=${STACK_NAME}
2+
3+
RABBIT_USER=${RABBIT_USER}
4+
RABBIT_PASSWORD=${RABBIT_PASSWORD}
5+
6+
RABBIT_DOCKER_SWARM_NETWORK_NAME=rabbit_rabbit_subnet

0 commit comments

Comments
 (0)