Skip to content

Commit

Permalink
Document the support for different metric types
Browse files Browse the repository at this point in the history
Signed-off-by: amirschw <24677563+amirschw@users.noreply.github.com>
  • Loading branch information
amirschw committed Feb 11, 2022
1 parent 721be10 commit b060d67
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 31 deletions.
2 changes: 1 addition & 1 deletion content/docs/2.7/concepts/external-scalers.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The `Scaler` interface defines 4 methods:
- `Close` is called to allow the scaler to clean up connections or other resources.
- `GetMetricSpec` returns the target value for the HPA definition for the scaler. For more details refer to [Implementing `GetMetricSpec`](#5-implementing-getmetricspec).
- `GetMetrics` returns the value of the metric referred to from `GetMetricSpec`. For more details refer to [Implementing `GetMetrics`](#6-implementing-getmetrics).
> Refer to the [HPA docs](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/) for how HPA calculates `replicaCount` based on metric value and target value. KEDA uses the metric target type `AverageValue` for external metrics. This will cause the metric value returned by the external scaler to be divided by the number of replicas.
> Refer to the [HPA docs](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/) for how HPA calculates `replicaCount` based on metric value and target value. KEDA supports both `AverageValue` and `Value` metric target types for external metrics. When `AverageValue` (the default metric type) is used, the metric value returned by the external scaler will be divided by the number of replicas.
The `PushScaler` interface adds a `Run` method. This method receives a push channel (`active`), on which the scaler can send `true` at any time. The purpose of this mechanism is to initiate a scaling operation independently from `pollingInterval`.

Expand Down
22 changes: 17 additions & 5 deletions content/docs/2.7/concepts/scaling-deployments.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ spec:
# {list of triggers to activate scaling of the target resource}
```

> 💡 **NOTE:** You can find all supported triggers [here](/scalers).
### Details
```yaml
scaleTargetRef:
Expand Down Expand Up @@ -116,7 +114,7 @@ The `cooldownPeriod` only applies after a trigger occurs; when you first create

> 💡 **NOTE:** Due to limitations in HPA controller the only supported value for this property is 0, it will not work correctly otherwise. See this [issue](https://github.com/kedacore/keda/issues/2314) for more details.

If this property is set, KEDA will scale the resource down to this number of replicas. If there's some activity on target triggers KEDA will scale the target resource immediately to `minReplicaCount` and then will be scaling handled by HPA. When there is no activity, the target resource is again scaled down to `idleReplicaCount`. This seting must be less than `minReplicaCount`.
If this property is set, KEDA will scale the resource down to this number of replicas. If there's some activity on target triggers KEDA will scale the target resource immediately to `minReplicaCount` and then will be scaling handled by HPA. When there is no activity, the target resource is again scaled down to `idleReplicaCount`. This setting must be less than `minReplicaCount`.

**Example:** If there's no activity on triggers the target resource is scaled down to `idleReplicaCount` (0), once there is an activity the target resource is immediately scaled to `minReplicaCount` (10) and then up to `maxReplicaCount` (100) as needed. If there's no activity on triggers the resource is again scaled down to `idleReplicaCount` (0).

Expand Down Expand Up @@ -155,10 +153,9 @@ Due to the HPA metric being of type `AverageValue` (see below), this will have t
**Example:** When my instance of prometheus is unavailable 3 consecutive times, KEDA will change the HPA metric such that the deployment will scale to 6 replicas.

There are a few limitations to using a fallback:
- It is **not** supported by the CPU & memory scalers and will assume that fallback is disabled in those cases. This is because it only supports scalers that present their target as an `AverageValue` metric.
- It only supports scalers if their target is an `AverageValue` metric. Thus, it is **not** supported by the CPU & memory scalers, or by scalers whose metric target type is `Value`, and will assume that fallback is disabled in those cases.
- It is only supported by `ScaledObjects` **not** `ScaledJobs`.


---
#### advanced
```yaml
Expand Down Expand Up @@ -195,6 +192,21 @@ Starting from Kubernetes v1.18 the autoscaling API allows scaling behavior to be

**Assumptions:** KEDA must be running on Kubernetes cluster v1.18+, in order to be able to benefit from this setting.

---
#### triggers
```yaml
triggers:
# {list of triggers to activate scaling of the target resource}
```

Trigger fields:
- **type**: Mandatory. The trigger type.
- **metadata**: Mandatory. A mapping of key-value parameters that describe the trigger.
- **authenticationRef**: Optional. A reference to the `TriggerAuthentication` or `ClusterTriggerAuthentication` object that is used to authenticate the scaler with the environment. More details can be found [here](/concepts/authentication).
- **metricType**: Optional. For all scalers other than CPU and memory, supported metric types are `AverageValue` and `Value`, with `AverageValue` as a default value. For CPU and memory scalers, `AverageValue` and `Utilization` are supported. Refer to the [HPA docs](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/) for how HPA calculates `replicaCount` based on metric type and value.

> 💡 **NOTE:** You can find all supported triggers [here](/scalers).

## Long-running executions

One important consideration to make is how this pattern can work with long running executions. Imagine a deployment triggers on a RabbitMQ queue message. Each message takes 3 hours to process. It's possible that if many queue messages arrive, KEDA will help drive scaling out to many replicas - let's say 4. Now the HPA makes a decision to scale down from 4 replicas to 2. There is no way to control which of the 2 replicas get terminated to scale down. That means the HPA may attempt to terminate a replica that is 2.9 hours into processing a 3 hour queue message.
Expand Down
40 changes: 20 additions & 20 deletions content/docs/2.7/operate/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ weight = 100

KEDA emits the following [Kubernetes Events](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#event-v1-core):

| Event | Type | Description |
|-------------------------------------|-----------|-----------------------------------------------------------------------------------------------------------------------------|
| `ScaledObjectReady` | `Normal` | On the first time a ScaledObject is ready, or if the previous ready condition status of the object was `Unknown` or `False` |
| `ScaledJobReady` | `Normal` | On the first time a ScaledJob is ready, or if the previous ready condition status of the object was `Unknown` or `False` |
| `ScaledObjectCheckFailed` | `Warning` | If the check validation for a ScaledObject fails |
| `ScaledJobCheckFailed` | `Warning` | If the check validation for a ScaledJob fails |
| `ScaledObjectDeleted` | `Normal` | When a ScaledObject is deleted and removed from KEDA watch |
| `ScaledJobDeleted` | `Normal` | When a ScaledJob is deleted and removed from KEDA watch |
| `KEDAScalersStarted` | `Normal` | When Scalers watch loop have started for a ScaledObject or ScaledJob |
| `KEDAScalersStopped` | `Normal` | When Scalers watch loop have stopped for a ScaledObject or a ScaledJob |
| `KEDAScalerFailed` | `Warning` | When a Scaler fails to create or check its event source |
| `KEDAScaleTargetActivated` | `Normal` | When the scale target (Deployment, StatefulSet, etc) of a ScaledObject is scaled to 1 |
| `KEDAScaleTargetDeactivated` | `Normal` | When the scale target (Deployment, StatefulSet, etc) of a ScaledObject is scaled to 0 |
| `KEDAScaleTargetActivationFailed` | `Warning` | When KEDA fails to scale the scale target of a ScaledObject to 1 |
| `KEDAScaleTargetDeactivationFailed` | `Warning` | When KEDA fails to scale the scale target of a ScaledObject to 0 |
| `KEDAJobsCreated` | `Normal` | When KEDA creates jobs for a ScaledJob |
| `TriggerAuthenticationAdded` | `Normal` | When a new TriggerAuthentication is added |
| `TriggerAuthenticationDeleted` | `Normal` | When a TriggerAuthentication is deleted |
| `ClusterTriggerAuthenticationAdded` | `Normal` | When a new ClusterTriggerAuthentication is added |
| `ClusterTriggerAuthenticationDeleted`| `Normal` | When a ClusterTriggerAuthentication is deleted |
| Event | Type | Description |
| ------------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------- |
| `ScaledObjectReady` | `Normal` | On the first time a ScaledObject is ready, or if the previous ready condition status of the object was `Unknown` or `False` |
| `ScaledJobReady` | `Normal` | On the first time a ScaledJob is ready, or if the previous ready condition status of the object was `Unknown` or `False` |
| `ScaledObjectCheckFailed` | `Warning` | If the check validation for a ScaledObject fails |
| `ScaledJobCheckFailed` | `Warning` | If the check validation for a ScaledJob fails |
| `ScaledObjectDeleted` | `Normal` | When a ScaledObject is deleted and removed from KEDA watch |
| `ScaledJobDeleted` | `Normal` | When a ScaledJob is deleted and removed from KEDA watch |
| `KEDAScalersStarted` | `Normal` | When Scalers watch loop have started for a ScaledObject or ScaledJob |
| `KEDAScalersStopped` | `Normal` | When Scalers watch loop have stopped for a ScaledObject or a ScaledJob |
| `KEDAScalerFailed` | `Warning` | When a Scaler fails to create or check its event source |
| `KEDAScaleTargetActivated` | `Normal` | When the scale target (Deployment, StatefulSet, etc) of a ScaledObject is scaled to 1 |
| `KEDAScaleTargetDeactivated` | `Normal` | When the scale target (Deployment, StatefulSet, etc) of a ScaledObject is scaled to 0 |
| `KEDAScaleTargetActivationFailed` | `Warning` | When KEDA fails to scale the scale target of a ScaledObject to 1 |
| `KEDAScaleTargetDeactivationFailed` | `Warning` | When KEDA fails to scale the scale target of a ScaledObject to 0 |
| `KEDAJobsCreated` | `Normal` | When KEDA creates jobs for a ScaledJob |
| `TriggerAuthenticationAdded` | `Normal` | When a new TriggerAuthentication is added |
| `TriggerAuthenticationDeleted` | `Normal` | When a TriggerAuthentication is deleted |
| `ClusterTriggerAuthenticationAdded` | `Normal` | When a new ClusterTriggerAuthentication is added |
| `ClusterTriggerAuthenticationDeleted` | `Normal` | When a ClusterTriggerAuthentication is deleted |
2 changes: 1 addition & 1 deletion content/docs/2.7/scalers/cassandra.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ triggers:
- `protocolVersion` - CQL Binary Protocol. (Default: `4`, Optional)
- `keyspace` - The name of the keyspace used in Cassandra.
- `query` - A Cassandra query that should return single numeric value.
- `targetQueryValue` - The threshold value that is provided by the user and used as `targetAverageValue` in the Horizontal Pod Autoscaler (HPA).
- `targetQueryValue` - The threshold value that is provided by the user and used as `targetValue` or `targetAverageValue` (depending on the trigger metric type) in the Horizontal Pod Autoscaler (HPA).
- `metricName` - Name to assign to the metric. (Default: `s<X>-cassandra-<KEYSPACE>`, Optional, In case of `metricName` is specified, it will be used to generate the `metricName` like this: `s<X>-cassandra-<METRICNAME>`, where `<X>` is the index of the trigger in a ScaledObject)

### Authentication Parameters
Expand Down
2 changes: 1 addition & 1 deletion content/docs/2.7/scalers/mssql.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ triggers:
The `mssql` trigger always requires the following information:

- `query` - A [T-SQL](https://docs.microsoft.com/sql/t-sql/language-reference) query that returns a single numeric value. This can be a regular query or the name of a stored procedure.
- `targetValue` - A threshold that is used as `targetAverageValue` in the Horizontal Pod Autoscaler (HPA).
- `targetValue` - A threshold that is used as `targetValue` or `targetAverageValue` (depending on the trigger metric type) in the Horizontal Pod Autoscaler (HPA).

To connect to the MSSQL instance, you can provide either:

Expand Down
2 changes: 1 addition & 1 deletion content/docs/2.7/scalers/mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This specification describes the `mysql` trigger that scales based on result of
The trigger always requires the following information:

- `query` - A MySQL query that should return single numeric value.
- `queryValue` - A threshold that is used as `targetAverageValue` in HPA.
- `queryValue` - A threshold that is used as `targetValue` or `targetAverageValue` (depending on the trigger metric type) in HPA.

To provide information about how to connect to MySQL you can provide:

Expand Down
2 changes: 1 addition & 1 deletion content/docs/2.7/scalers/new-relic.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ triggers:
- `region` - The region to connect to for the New Relic apis. (Values: `LOCAL`, `EU`, `STAGING`, `US`, Default: `US`, Optional)
- `noDataError` - Should queries that return nodata be treated as an error (Values: `true`, `false`, Default: `false`, Optional)
- `nrql` - The New Relic query that will be run to get the data requested. [official documentation](https://docs.newrelic.com/docs/query-your-data/nrql-new-relic-query-language/get-started/introduction-nrql-new-relics-query-language/)
- `threshold` - A threshold that is used as the `targetAverageValue` in the HPA configuration.
- `threshold` - A threshold that is used as the `targetValue` or `targetAverageValue` (depending on the trigger metric type) in the HPA configuration.

### Authentication Parameters

Expand Down
2 changes: 1 addition & 1 deletion content/docs/2.7/scalers/postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internally.
Finally, a user inserts a query that returns the desired value.

- `query` - What query to poll postgresql with. Query must return an integer.
- `targetQueryValue` - A threshold that is used as `targetAverageValue` in HPA.
- `targetQueryValue` - A threshold that is used as `targetValue` or `targetAverageValue` (depending on the trigger metric type) in HPA.
- `metricName` - Name to assign to the metric. If not set KEDA will generate a name based on either the connection string if set or the db name. If using more than one trigger it is required that all metricNames be unique. (Optional)

This is an example of using a full connection string with `AIRFLOW_CONN_AIRFLOW_DB` set as `postgresql://test@localhost`:
Expand Down

0 comments on commit b060d67

Please sign in to comment.