Skip to content

Commit

Permalink
document new publishRate trigger (#388)
Browse files Browse the repository at this point in the history
Co-authored-by: Karg <rkarg@blizzard.com>
  • Loading branch information
rwkarg and rkarg-blizz authored Mar 9, 2021
1 parent ce5aa9a commit db8d2d1
Showing 1 changed file with 63 additions and 7 deletions.
70 changes: 63 additions & 7 deletions content/docs/2.2/scalers/rabbitmq-queue.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ triggers:
metadata:
host: amqp://localhost:5672/vhost # Optional. If not specified, it must be done by using TriggerAuthentication.
protocol: auto # Optional. Specifies protocol to use, either amqp or http, or auto to autodetect based on the `host` value. Default value is auto.
queueLength: '20' # Optional. Queue length target for HPA. Default: 20 messages
mode: QueueLength # QueueLength or MessageRate
value: 100 # message backlog or publish/sec. target per instance
queueName: testqueue
vhostName: / # Optional. If not specified, use the vhost in the `host` connection string.
# Alternatively, you can use existing environment variables to read configuration from:
Expand All @@ -27,23 +28,28 @@ triggers:
**Parameter list:**
- `host`: Host of RabbitMQ with format `amqp://<host>:<port>/vhost`. The resolved host should follow a format like `amqp://guest:password@localhost:5672/vhost` or
- `host`: Host of RabbitMQ with format `<protocol>://<host>:<port>/vhost`. The resolved host should follow a format like `amqp://guest:password@localhost:5672/vhost` or
`http://guest:password@localhost:15672/vhost`. When using a username/password consider using `hostFromEnv` or a TriggerAuthentication.

- `queueName`: Name of the queue to read message from. Required.
- `queueLength`: Target value for queue length passed to the scaler. Example: if one pod can handle 10 messages, set the queue length target to 10. If the actual number of messages in the queue is 30, the scaler scales to 3 pods. Default is 20. Optional.
- `mode`: QueueLength to trigger on number of messages in the queue. MessageRate to trigger on the publish rate into the queue. Required.
- `value`: Message backlog or Publish/sec. rate to trigger on
- `protocol`: Protocol to be used for communication. Either `auto`, `http`, or `amqp`. It should correspond with the `host` value. Optional, will autodetect based on the `host` URL if possible.
- `vhostName`: Vhost to use for the connection, overrides any vhost set in the connection string from `host`/`hostFromEnv`.

- `queueLength`: DEPRECATED! Use `mode: QueueLength` and `value: ##` instead. Target value for queue length passed to the scaler. Example: if one pod can handle 10 messages, set the queue length target to 10. If the actual number of messages in the queue is 30, the scaler scales to 3 pods. Default is 20 unless `publishRate` is specified, in which case `queueLength` is disabled for this trigger.

Some parameters could be provided using environmental variables, instead of setting them directly in metadata. Here is a list of parameters you can use to retrieve values from environment variables:

- `hostFromEnv`: The host and port of the Redis server, similar to `host`, but reads it from an environment variable on the scale target.

> 💡 **Note:** `host`/`hostFromEnv` has an optional vhost name after the host slash which will be used to scope API request.

> 💡 **Note:** `mode: MessageRate` requires protocol `http`.

> ⚠ **Important:** if you have unacknowledged messages and want to have these counted for the scaling to happen, make sure to utilize the `http` REST API interface which allows for these to be counted.

> ⚠ **Important:** If scaling against both is desired then the `ScaledObject` should have two triggers, one for `mode: QueueLength` and the other for `mode: MessageRate`. HPA will scale based on the largest result considering each of the two triggers independently.

### Authentication Parameters

TriggerAuthentication CRD is used to connect and authenticate to RabbitMQ:
Expand Down Expand Up @@ -89,12 +95,53 @@ spec:
metadata:
protocol: amqp
queueName: testqueue
queueLength: "20"
mode: QueueLength
value: "20"
authenticationRef:
name: keda-trigger-auth-rabbitmq-conn
```

#### HTTP protocol (`QueueLength`):

```yaml
apiVersion: v1
kind: Secret
metadata:
name: keda-rabbitmq-secret
data:
host: <HTTP API endpoint> # base64 encoded value of format http://guest:password@localhost:15672/vhost
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-rabbitmq-conn
namespace: default
spec:
secretTargetRef:
- parameter: host
name: keda-rabbitmq-secret
key: host
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: rabbitmq-scaledobject
namespace: default
spec:
scaleTargetRef:
name: rabbitmq-deployment
triggers:
- type: rabbitmq
metadata:
protocol: http
queueName: testqueue
mode: QueueLength
value: "20"
authenticationRef:
name: keda-trigger-auth-rabbitmq-conn
```

#### HTTP protocol:
#### HTTP protocol (`MessageRate` and `QueueLength`):

```yaml
apiVersion: v1
Expand Down Expand Up @@ -128,7 +175,16 @@ spec:
metadata:
protocol: http
queueName: testqueue
queueLength: "20"
mode: QueueLength
value: "20"
authenticationRef:
name: keda-trigger-auth-rabbitmq-conn
- type: rabbitmq
metadata:
protocol: http
queueName: testqueue
mode: MessageRate
value: "100"
authenticationRef:
name: keda-trigger-auth-rabbitmq-conn
```

0 comments on commit db8d2d1

Please sign in to comment.