Skip to content

Commit

Permalink
Update: adds vhost configuration details from onfido#5
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Mills committed Jul 3, 2020
1 parent 6cfb9f7 commit 2484ce3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions autoscale.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/%2f$vhostName/$queueName)

if [[ $? -eq 0 ]]; then
queueMessages=$(echo $queueMessagesJson | jq '.messages')
Expand Down
4 changes: 2 additions & 2 deletions deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2484ce3

Please sign in to comment.