Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

add custom vhost support #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -20,8 +20,8 @@ This Pod runs in the `kube-system` namespace on k8s master nodes.
- `RABBIT_USER`: Username used for authentication with the RabbitMQ API (check `deploy.yml`, defaults to `rabbit-pod-autoscaler` secret, `rabbit-user` key)
- `RABBIT_PASS`: Password used for authentication with the RabbitMQ API (check `deploy.yml`, defaults to `rabbit-pod-autoscaler` secret, `rabbit-pass` key)
- `AUTOSCALING`: Contains min/max pods, messages handled per pod, deployment info and queue name in the following pattern:
- single deployment to autoscale: `<minPods>|<maxPods>|<mesgPerPod>|<k8s namespace>|<k8s deployment name>|<RabbitMQ queue name>`
- e.g. `3|10|5|development|example|example.queue`
- single deployment to autoscale: `<minPods>|<maxPods>|<mesgPerPod>|<k8s namespace>|<k8s deployment name>|<RabbitMQ queue name>|<RabbitMQ vhost name>`
- e.g. `3|10|5|development|example|example.queue|rabbitmq.vhost`
- `mesgPerPod` represents the amount of RabbitMQ messages a Pod can process within the `INTERVAL` (env var). As an example, if a Pod needs 6s to process a message from RabbitMQ, the `mesgPerPod` value will be `INTERVAL (30s) / process time (6s) = 5`.
- multiple deployments to autoscale: check example `deploy.yml`
- `LOGS`: Logging and Slack notifications intensity. Errors are logged and notified on every option
6 changes: 4 additions & 2 deletions autoscale.sh
Original file line number Diff line number Diff line change
@@ -33,10 +33,12 @@ IFS=';' read -ra autoscalingArr <<< "$autoscalingNoWS"

while true; do
for autoscaler in "${autoscalingArr[@]}"; do
IFS='|' read minPods maxPods mesgPerPod namespace deployment queueName <<< "$autoscaler"
IFS='|' read minPods maxPods mesgPerPod namespace deployment queueName vhostName <<< "$autoscaler"

vhostName=${vhostName:-"%2f"}

queueMessagesJson=$(curl -s -S --retry 3 --retry-delay 3 -u $RABBIT_USER:$RABBIT_PASS \
$RABBIT_HOST:15672/api/queues/%2f/$queueName)
$RABBIT_HOST:15672/api/queues/$vhostName/$queueName)

if [[ $? -eq 0 ]]; then
queueMessages=$(echo $queueMessagesJson | jq '.messages')
4 changes: 2 additions & 2 deletions deploy.yml
Original file line number Diff line number Diff line change
@@ -70,8 +70,8 @@ spec:
key: rabbit-pass
- name: AUTOSCALING
value: >
3|10|5|development|example|example.queue;
3|5|3|development|example2|example2.queue
3|10|5|development|example|example.queue|vhost;
3|5|3|development|example2|example2.queue|vhost
- name: LOGS
value: HIGH
- name: SLACK_HOOK