Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide support for scaling based on Redis Key-Values #1493

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
+++
title = "Redis Lists (supports Redis Cluster)"
title = "Redis Lists Or Strings (supports Redis Cluster)"
availability = "v2.1+"
maintainer = "Community"
category = "Data & Storage"
description = "Redis Lists scaler with support for Redis Cluster topology"
description = "Redis Lists or Strings scaler with support for Redis Cluster topology"
go_file = "redis_scaler"
+++

### Trigger Specification

This specification describes the `redis-cluster` trigger that scales based on the length of a list in a Redis Cluster.
This specification describes the `redis-cluster` trigger that scales based on the length of a list or string in a Redis Cluster.

```yaml
triggers:
Expand All @@ -18,9 +18,12 @@ triggers:
addresses: localhost:6379 # Comma separated list of the format host:port
usernameFromEnv: REDIS_USERNAME # optional
passwordFromEnv: REDIS_PASSWORD
listName: mylist # Required
listLength: "5" # Required
listName: mylist # optional
listLength: "5" # optional
activationListLength: "5" # optional
keyName: mykey # optional
keyValue: "1.5" # optional
activationValue: "5" # optional
enableTLS: "false" # optional
unsafeSsl: "false" # optional
databaseIndex: "0" # optional
Expand All @@ -37,9 +40,12 @@ triggers:
- `usernameFromEnv` - Environment variable to read the authentication username from to authenticate with the Redis server.
- `passwordFromEnv` - Environment variable to read the authentication password from to authenticate with the Redis server.
- Both the hostname, username and password fields need to be set to the names of the environment variables in the target deployment that contain the host name, username and password respectively.
- `listName` - Name of the Redis List that you want to monitor.
- `listLength` - Average target value to trigger scaling actions.
- `activationListLength` - Target value for activating the scaler. Learn more about activation [here](./../concepts/scaling-deployments.md#activating-and-scaling-thresholds). (Default: `0`, Optional)
- `listName` - Name of the Redis List that you want to monitor. One of `listName` or `keyName` must be set, and cannot be set at the same time. (Optional, Mutually exclusive with `keyName`)
- `listLength` - Average target value to trigger scaling actions, make sense only when using with `listName`.(Optional, Mutually exclusive with `keyValue`)
- `activationListLength` - Target value for activating the scaler, make sense only when using with `listName`. Learn more about activation [here](./../concepts/scaling-deployments.md#activating-and-scaling-thresholds). (Default: `0`, Optional)
- `keyName` - Name of the Redis Key that you want to monitor. One of `listName` or `keyName` must be set, and cannot be set at the same time. (Optional, Mutually exclusive with `listName`)
- `keyValue` - Average target value to trigger scaling actions, make sense only when using with `keyName`. (Optional, Mutually exclusive with `listLength`)
- `activationValue` - Target value for activating the scaler, make sense only when using with `keyName`. Learn more about activation [here](./../concepts/scaling-deployments.md#)
- `enableTLS` - Allow a connection to a redis queue using tls. (Values: `true`, `false`, Default: `false`, Optional)
- `unsafeSsl` - Used for skipping certificate check e.g: using self-signed certs. (Values: `true`,`false`, Default: `false`, Optional, This requires `enableTLS: true`)
- `databaseIndex` - Index of Redis database to use. If not specified, the default value is 0.
Expand Down Expand Up @@ -77,7 +83,7 @@ Parameters used for configuring TLS authentication. Note this can not be used to

### Example

Here is an example of how to deploy a scaled object with the `redis-cluster` scale trigger which uses `TriggerAuthentication`.
Here is an example of how to deploy a scaled object with the `redis-cluster` scale trigger which uses `TriggerAuthentication`, and monitor a Redis List named `mylist`.

You can also provide the `usernameFromEnv` and `passwordFromEnv` on the `ScaledObject` directly.

Expand Down Expand Up @@ -123,3 +129,48 @@ spec:
authenticationRef:
name: keda-trigger-auth-redis-secret
```

Here is an example of how to deploy a scaled object with the `redis` scale trigger which uses `Key` instead of `List`.

```yaml
apiVersion: v1
kind: Secret
metadata:
name: votes-db-secret
namespace: my-project
type: Opaque
data:
redis_username: YWRtaW4=
redis_password: YWRtaW4=
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-redis-secret
namespace: my-project
spec:
secretTargetRef:
- parameter: username
name: votes-db-secret
key: redis_username
- parameter: password
name: votes-db-secret
key: redis_password
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: redis-scaledobject
namespace: my-project
spec:
scaleTargetRef:
name: votes
triggers:
- type: redis-cluster
metadata:
addresses: node1:6379, node2:6379, node3:6379
keyName: mykey
keyValue: "10"
authenticationRef:
name: keda-trigger-auth-redis-secret
```
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
+++
title = "Redis Lists (supports Redis Sentinel)"
title = "Redis Lists Or Strings (supports Redis Sentinel)"
availability = "v2.5+"
maintainer = "Community"
category = "Data & Storage"
description = "Redis Lists scaler with support for Redis Sentinel topology"
description = "Redis Lists or Strings scaler with support for Redis Sentinel topology"
go_file = "redis_scaler"
+++

### Trigger Specification

This specification describes the `redis-sentinel` trigger that scales based on the length of a list in a Redis Sentinel setup.
This specification describes the `redis-sentinel` trigger that scales based on the length of a list or string in a Redis Sentinel setup.

```yaml
triggers:
Expand All @@ -21,9 +21,12 @@ triggers:
sentinelUsernameFromEnv: REDIS_SENTINEL_USERNAME # optional
sentinelPasswordFromEnv: REDIS_SENTINEL_PASSWORD # optional
sentinelMasterFromEnv: REDIS_SENTINEL_MASTER # optional
listName: mylist # Required
listLength: "5" # Required
listName: mylist # optional
listLength: "5" # optional
activationListLength: "5" # optional
keyName: mykey # optional
keyValue: "1.5" # optional
activationValue: "5" # optional
enableTLS: "false" # optional
unsafeSsl: "false" # optional
databaseIndex: "0" # optional
Expand All @@ -43,9 +46,12 @@ triggers:
- `sentinelUsernameFromEnv` - Environment variable to read the authentication username from to authenticate with the Redis Sentinel server.
- `sentinelPasswordFromEnv` - Environment variable to read the authentication password from to authenticate with the Redis Sentinel server.
- sentinelMaster - The name of the primary (still referred to as the 'master' in Sentinel) to get the Redis server address for.
- `listName` - Name of the Redis List that you want to monitor.
- `listLength` - Average target value to trigger scaling actions.
- `activationListLength` - Target value for activating the scaler. Learn more about activation [here](./../concepts/scaling-deployments.md#activating-and-scaling-thresholds). (Default: `0`, Optional)
- `listName` - Name of the Redis List that you want to monitor. One of `listName` or `keyName` must be set, and cannot be set at the same time. (Optional, Mutually exclusive with `keyName`)
- `listLength` - Average target value to trigger scaling actions, make sense only when using with `listName`.(Optional, Mutually exclusive with `keyValue`)
- `activationListLength` - Target value for activating the scaler, make sense only when using with `listName`. Learn more about activation [here](./../concepts/scaling-deployments.md#activating-and-scaling-thresholds). (Default: `0`, Optional)
- `keyName` - Name of the Redis Key that you want to monitor. One of `listName` or `keyName` must be set, and cannot be set at the same time. (Optional, Mutually exclusive with `listName`)
- `keyValue` - Average target value to trigger scaling actions, make sense only when using with `keyName`. (Optional, Mutually exclusive with `listLength`)
- `activationValue` - Target value for activating the scaler, make sense only when using with `keyName`. Learn more about activation [here](./../concepts/scaling-deployments.md#)
- `enableTLS` - Allow a connection to a redis queue using tls. (Values: `true`, `false`, Default: `false`, Optional)
- `unsafeSsl` - Used for skipping certificate check e.g: using self-signed certs. (Values: `true`,`false`, Default: `false`, Optional, This requires `enableTLS: true`)
- `databaseIndex` - Index of Redis database to use. If not specified, the default value is 0.
Expand Down Expand Up @@ -91,7 +97,7 @@ Parameters used for configuring TLS authentication. Note this can not be used to

### Example

Here is an example of how to deploy a scaled object with the `redis-sentinel` scale trigger which uses `TriggerAuthentication`.
Here is an example of how to deploy a scaled object with the `redis` scale trigger which uses `TriggerAuthentication`, and monitor a Redis List named `mylist`.

You can also provide the `usernameFromEnv` and `passwordFromEnv` on the `ScaledObject` directly.

Expand Down Expand Up @@ -138,3 +144,48 @@ spec:
authenticationRef:
name: keda-trigger-auth-redis-secret
```

Here is an example of how to deploy a scaled object with the `redis` scale trigger which uses `Key` instead of `List`.
```yaml
apiVersion: v1
kind: Secret
metadata:
name: votes-db-secret
namespace: my-project
type: Opaque
data:
redis_username: YWRtaW4=
redis_password: YWRtaW4=
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-redis-secret
namespace: my-project
spec:
secretTargetRef:
- parameter: username
name: votes-db-secret
key: redis_username
- parameter: password
name: votes-db-secret
key: redis_password
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: redis-scaledobject
namespace: my-project
spec:
scaleTargetRef:
name: votes
triggers:
- type: redis-sentinel
metadata:
addresses: node1:26379, node2:26379, node3:26379
keyName: mykey
keyValue: "10"
sentinelMaster: "myprimary"
authenticationRef:
name: keda-trigger-auth-redis-secret
```
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
+++
title = "Redis Lists"
title = "Redis Lists Or Strings"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed redis-lists.md to redis.md because there is more than just a list, is this acceptable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this could break the current naming of the urls. @zroubalik @wozniakjan ?

Copy link
Member

@wozniakjan wozniakjan Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case, we should probably also rename all the references, no?

not sure how many of these are relevant for a rename

$ grep . -nre '/scalers/redis-lists' | wc -l
1448

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If change, then I would probably go with just Redis

Do you mean breaking urls between versions of this scaler, or what? Then we can probably try to find a solution or just keep the original name.

availability = "v1.0+"
maintainer = "Community"
category = "Data & Storage"
description = "Scale applications based on Redis Lists."
description = "Scale applications based on Redis Lists Or Strings."
go_file = "redis_scaler"
+++

### Trigger Specification

This specification describes the `redis` trigger that scales based on the length of a list in Redis.
This specification describes the `redis` trigger that scales based on the length of a list or string in Redis.

```yaml
triggers:
Expand All @@ -18,9 +18,12 @@ triggers:
address: localhost:6379 # Format must be host:port
usernameFromEnv: REDIS_USERNAME # optional
passwordFromEnv: REDIS_PASSWORD
listName: mylist # Required
listLength: "5" # Required
listName: mylist # optional
listLength: "5" # optional
activationListLength: "5" # optional
keyName: mykey # optional
keyValue: "1.5" # optional
activationValue: "5" # optional
enableTLS: "false" # optional
unsafeSsl: "false" # optional
databaseIndex: "0" # optional
Expand All @@ -37,9 +40,12 @@ triggers:
- `usernameFromEnv` - Environment variable to read the authentication username from to authenticate with the Redis server.
- `passwordFromEnv` - Environment variable to read the authentication password from to authenticate with the Redis server.
- Both the hostname, username and password fields need to be set to the names of the environment variables in the target deployment that contain the host name, username and password respectively.
- `listName` - Name of the Redis List that you want to monitor.
- `listLength` - Average target value to trigger scaling actions.
- `activationListLength` - Target value for activating the scaler. Learn more about activation [here](./../concepts/scaling-deployments.md#activating-and-scaling-thresholds). (Default: `0`, Optional)
- `listName` - Name of the Redis List that you want to monitor. One of `listName` or `keyName` must be set, and cannot be set at the same time. (Optional, Mutually exclusive with `keyName`)
- `listLength` - Average target value to trigger scaling actions, make sense only when using with `listName`.(Optional, Mutually exclusive with `keyValue`)
- `activationListLength` - Target value for activating the scaler, make sense only when using with `listName`. Learn more about activation [here](./../concepts/scaling-deployments.md#activating-and-scaling-thresholds). (Default: `0`, Optional)
- `keyName` - Name of the Redis Key that you want to monitor. One of `listName` or `keyName` must be set, and cannot be set at the same time. (Optional, Mutually exclusive with `listName`)
- `keyValue` - Average target value to trigger scaling actions, make sense only when using with `keyName`. (Optional, Mutually exclusive with `listLength`)
- `activationValue` - Target value for activating the scaler, make sense only when using with `keyName`. Learn more about activation [here](./../concepts/scaling-deployments.md#)
- `enableTLS` - Allow a connection to a redis queue using tls. (Values: `true`, `false`, Default: `false`, Optional)
- `unsafeSsl` - Used for skipping certificate check e.g: using self-signed certs. (Values: `true`,`false`, Default: `false`, Optional, This requires `enableTLS: true`)
- `databaseIndex` - Index of Redis database to use. If not specified, the default value is 0.
Expand Down Expand Up @@ -77,7 +83,7 @@ Parameters used for configuring TLS authentication. Note this can not be used to

### Example

Here is an example of how to deploy a scaled object with the `redis` scale trigger which uses `TriggerAuthentication`.
Here is an example of how to deploy a scaled object with the `redis` scale trigger which uses `TriggerAuthentication`, and monitor a Redis List named `mylist`.

You can also provide the `usernameFromEnv` and `passwordFromEnv` on the `ScaledObject` directly.

Expand Down Expand Up @@ -123,3 +129,48 @@ spec:
authenticationRef:
name: keda-trigger-auth-redis-secret
```

Here is an example of how to deploy a scaled object with the `redis` scale trigger which uses `Key` instead of `List`.

```yaml
apiVersion: v1
kind: Secret
metadata:
name: votes-db-secret
namespace: my-project
type: Opaque
data:
redis_username: YWRtaW4=
redis_password: YWRtaW4=
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-redis-secret
namespace: my-project
spec:
secretTargetRef:
- parameter: username
name: votes-db-secret
key: redis_username
- parameter: password
name: votes-db-secret
key: redis_password
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: redis-scaledobject
namespace: my-project
spec:
scaleTargetRef:
name: votes
triggers:
- type: redis
metadata:
address: localhost:6379
keyName: mykey
keyValue: "10"
authenticationRef:
name: keda-trigger-auth-redis-secret
```
Loading