Skip to content
Open
6 changes: 6 additions & 0 deletions cluster-install/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Install a new node
1. Install the `gcloud`
2.
Run `00_create_machine.sh` from your local environment

`gcloud compute scp ./cluster-install/install-scripts/*.sh rabbitmq-1:~/`
9 changes: 9 additions & 0 deletions cluster-install/TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# TODO

1. Check `sudo`
2. Exit at first error
3. First script returns the `ERLANG_COOKIE`
4. Set feature flag `detailed_queues_endpoint` as enabled (~ `rabbitmqctl enable_feature_flag detailed_queues_endpoint` )
5. track firewall rule creation

COOKIE = YVIRLAAERJPTQKTYMACZ
19 changes: 19 additions & 0 deletions cluster-install/install-scripts/00_create_machine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## to be run on local machine
gcloud compute instances create $1 \
--project=rabbit-test-406509 \
--zone=europe-west1-b \
--machine-type=e2-micro \
--network-interface=network-tier=PREMIUM,stack-type=IPV4_ONLY,subnet=default \
--maintenance-policy=MIGRATE \
--provisioning-model=STANDARD \
--service-account=99473582712-compute@developer.gserviceaccount.com \
--scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/trace.append \
--tags=allow-tcp-15672,http-server,https-server \
--create-disk=auto-delete=yes,boot=yes,device-name=$1,image=projects/ubuntu-os-cloud/global/images/ubuntu-2204-jammy-v20240228,mode=rw,size=10,type=projects/rabbit-test-406509/zones/europe-west1-b/diskTypes/pd-balanced \
--no-shielded-secure-boot \
--shielded-vtpm \
--shielded-integrity-monitoring \
--labels=goog-ec-src=vm_add-gcloud \
--reservation-affinity=any

# gcloud compute scp ./cluster-install/install-scripts/*.sh rabbitmq-1:~/
76 changes: 76 additions & 0 deletions cluster-install/install-scripts/01_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash
#usage
# $> sudo 01_setup.sh ["rabbitmq-server 3 minor version"]
#
echo "---------------------"
echo "Installing base tools"
echo "---------------------"
apt-get update -y
apt-get install curl gnupg apt-transport-https net-tools -y

echo "----------------------------"
echo "Adding rabbitmq repositories"
echo "----------------------------"
./cloudsmith_repos.sh

echo "-------------------------"
echo "Indexing new repositories"
echo "-------------------------"
## Update package indices
apt-get update -y

echo "-----------------"
echo "Installing erlang"
echo "-----------------"
## Install Erlang packages
apt-get install -y erlang-base \
erlang-asn1 erlang-crypto erlang-eldap erlang-ftp erlang-inets \
erlang-mnesia erlang-os-mon erlang-parsetools erlang-public-key \
erlang-runtime-tools erlang-snmp erlang-ssl \
erlang-syntax-tools erlang-tftp erlang-tools erlang-xmerl


## Install rabbitmq-server and its dependencies
if [ -z "$1" ]; then
echo "-------------------"
echo "Installing latest version of rabbitmq"
echo "-------------------"
sudo apt-get install rabbitmq-server -y --fix-missing
else
latest_patch=$(apt list -a rabbitmq-server 2>/dev/null | grep -oP "3.12.\K(\d{1,2}-\d{1,2})" | sort -V | tail -n 1)
if [ -z "$latest_patch" ]; then
echo "...could not find any version of minor $1, aborting"
exit 1
fi
echo "-------------------"
echo "Installing version 3.$1.$latest_patch of rabbitmq"
echo "-------------------"
sudo apt-get install rabbitmq-server=3.$1.$latest_patch -y --fix-missing
fi

echo "---------------------------"
echo "Enabling rabbitmq at startup"
echo "---------------------------"
#start rabbitmq and make it run at startup
systemctl enable rabbitmq-server
sleep 30

echo "--------------------------"
echo "Enabling management plugin"
echo "--------------------------"
#enable management plugin
rabbitmq-plugins enable rabbitmq_management
#metrics for prometheus
rabbitmq-plugins enable rabbitmq_prometheus

echo "----------------------------------------------"
echo "Enabling feature flag detailed_queues_endpoint"
echo "----------------------------------------------"
rabbitmqctl enable_feature_flag detailed_queues_endpoint

echo "-------------------"
echo "Adding default user"
echo "-------------------"
rabbitmqctl add_user rabbit rabbit
rabbitmqctl set_user_tags rabbit administrator
rabbitmqctl set_permissions -p / rabbit ".*" ".*" ".*"
31 changes: 31 additions & 0 deletions cluster-install/install-scripts/02_setup_cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
#First setup the node with setup.sh, then use this script to join a cluster.
#usage
# $> sudo 02_setup_cluster.sh "rabbit@the-cluster-node" "the-erlang-cookie"
#
SETUP_CLUSTER_HOST=$1
SETUP_ERLANG_COOKIE=$2

#overwrite the erlang cookie
./set_erlang_cookie.sh $SETUP_ERLANG_COOKIE


#prepare the local node to join the cluster
echo "--------------------------------------------"
echo "Preparing the local node to join the cluster"
echo "--------------------------------------------"
rabbitmqctl stop_app
rabbitmqctl reset


#join operation request
echo "----------------------------------------------------------"
echo "Issuing cluster join request to node ${SETUP_CLUSTER_HOST}"
echo "----------------------------------------------------------"
rabbitmqctl join_cluster $SETUP_CLUSTER_HOST

#start node apps
echo "------------------------------"
echo "Starting internal rabbitmq app"
echo "------------------------------"
rabbitmqctl start_app
31 changes: 31 additions & 0 deletions cluster-install/install-scripts/cloudsmith_repos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh
distribution="jammy"

## Team RabbitMQ's main signing key
curl -1sLf "https://keys.openpgp.org/vks/v1/by-fingerprint/0A9AF2115F4687BD29803A206B73A36E6026DFCA" | gpg --dearmor | tee /usr/share/keyrings/com.rabbitmq.team.gpg > /dev/null
## Community mirror of Cloudsmith: modern Erlang repository
curl -1sLf https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key | gpg --dearmor | tee /usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg > /dev/null
## Community mirror of Cloudsmith: RabbitMQ repository
curl -1sLf https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.9F4587F226208342.key | gpg --dearmor | tee /usr/share/keyrings/rabbitmq.9F4587F226208342.gpg > /dev/null

## Add apt repositories maintained by Team RabbitMQ
tee /etc/apt/sources.list.d/rabbitmq.list <<EOF
## Provides modern Erlang/OTP releases
##
deb [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu ${distribution} main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu ${distribution} main

# another mirror for redundancy
deb [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu ${distribution} main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu ${distribution} main

## Provides RabbitMQ
##
deb [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu ${distribution} main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu ${distribution} main

# another mirror for redundancy
deb [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu ${distribution} main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu ${distribution} main
EOF

29 changes: 29 additions & 0 deletions cluster-install/install-scripts/set_erlang_cookie.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
#Overwrites the current erlang cookie
#usage
# $> sudo ./set_erlang_cookie.sh "the-erlang-cookie"

SETUP_ERLANG_COOKIE=$1

if [ ! -z $1 ]
then
echo "--------------------------------------------------------"
echo "setting rabbitmq erlang cookie to ${SETUP_ERLANG_COOKIE}"
echo "--------------------------------------------------------"
#overwrite the erlang cookie
systemctl stop rabbitmq-server
chmod 666 /var/lib/rabbitmq/.erlang.cookie
echo -n $SETUP_ERLANG_COOKIE > /var/lib/rabbitmq/.erlang.cookie
chmod 400 /var/lib/rabbitmq/.erlang.cookie
systemctl start rabbitmq-server
sleep 30
else
echo "-------------------------------------"
echo "Skipping rabbitmq erlang cookie setup"
echo "-------------------------------------"
fi





94 changes: 94 additions & 0 deletions docker-compose/alert-manager.yml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
global:
smtp_smarthost: 'smtp4dev:25'
smtp_from: '[email protected]'
smtp_require_tls: false

route:
group_by: ["group"]
receiver: team-mails
routes:
- receiver: team-mails
# time to wait for grouping alarms when sending the first notification
group_wait: 30s
# time to wait for grouping new alarms when sending further notifications for the same group
group_interval: 1m
# should be a multiple of group_interval
repeat_interval: 2h
mute_time_intervals: ["weekday-off-evenings", "weekday-off-mornings", "weekends"]
matchers:
- severity =~ "warning|critical"
- receiver: team-slack-and-emails
# time to wait for grouping alarms when sending the first notification
group_wait: 30s
# time to wait for grouping new alarms when sending further notifications for the same group
group_interval: 1m
# should be a multiple of group_interval
repeat_interval: 2m
matchers:
- severity =~ "critical"

time_intervals:
- name: "working-hours"
time_intervals:
- times:
- start_time: "09:00"
end_time: "18:00"
location: "Europe/Rome"
weekdays: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']
- name: "weekday-off-evenings"
time_intervals:
- times:
- start_time: "18:00"
end_time: "23:59"
location: "Europe/Rome"
weekdays: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']
- name: "weekday-off-mornings"
time_intervals:
- times:
- start_time: "00:00"
end_time: "08:59"
location: "Europe/Rome"
weekdays: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']
- name: "weekends"
time_intervals:
- times:
- start_time: "00:00"
end_time: "23:59"
location: "Europe/Rome"
weekdays: ['Saturday', 'Sunday']

receivers:
- name: "team-mails"
email_configs:
- to: "[email protected]"
send_resolved: true
- name: "team-slack-and-emails"
email_configs:
- to: "[email protected]"
send_resolved: true
slack_configs:
- send_resolved: true
channel: "#rabbitmq-management"
api_url: "env.SLACK_API_URL"
title: |-
[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .CommonLabels.alertname }} for {{ .CommonLabels.job }}
{{- if gt (len .CommonLabels) (len .GroupLabels) -}}
{{" "}}(
{{- with .CommonLabels.Remove .GroupLabels.Names }}
{{- range $index, $label := .SortedPairs -}}
{{ if $index }}, {{ end }}
{{- $label.Name }}="{{ $label.Value -}}"
{{- end }}
{{- end -}}
)
{{- end }}
text: >-
{{ range .Alerts -}}
*Alert:* {{ .Annotations.title }}{{ if .Labels.severity }} - `{{ .Labels.severity }}`{{ end }}

*Description:* {{ .Annotations.description }}

*Details:*
{{ range .Labels.SortedPairs }} • *{{ .Name }}:* `{{ .Value }}`
{{ end }}
{{ end }}
Loading