diff --git a/README.md b/README.md index 95ce14f..afd6a7e 100644 --- a/README.md +++ b/README.md @@ -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: `|||||` - - e.g. `3|10|5|development|example|example.queue` + - single deployment to autoscale: `||||||` + - 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 diff --git a/autoscale.sh b/autoscale.sh index 619552a..c12d20d 100644 --- a/autoscale.sh +++ b/autoscale.sh @@ -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') diff --git a/deploy.yml b/deploy.yml index c225150..904d194 100644 --- a/deploy.yml +++ b/deploy.yml @@ -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