You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: content/docs/2.12/concepts/scaling-deployments.md
+86-4
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ The only constraint is that the target `Custom Resource` must define `/scale` [s
29
29
30
30
## ScaledObject spec
31
31
32
-
This specification describes the `ScaledObject` Custom Resource definition which is used to define how KEDA should scale your application and what the triggers are. The `.spec.ScaleTargetRef` section holds the reference to the target resource, ie. `Deployment`, `StatefulSet` or `Custom Resource`.
32
+
This specification describes the `ScaledObject` Custom Resource definition which is used to define how KEDA should scale your application and what the triggers are. The `.spec.ScaleTargetRef` section holds the reference to the target resource, ie. `Deployment`, `StatefulSet` or `Custom Resource`.
idleReplicaCount: 0# Optional. Default: ignored, must be less than minReplicaCount
52
+
idleReplicaCount: 0# Optional. Default: ignored, must be less than minReplicaCount
53
53
minReplicaCount: 1# Optional. Default: 0
54
54
maxReplicaCount: 100# Optional. Default: 100
55
55
fallback: # Optional. Section to specify fallback options
@@ -113,7 +113,7 @@ The `cooldownPeriod` only applies after a trigger occurs; when you first create
113
113
#### idleReplicaCount
114
114
115
115
```yaml
116
-
idleReplicaCount: 0 # Optional. Default: ignored, must be less than minReplicaCount
116
+
idleReplicaCount: 0 # Optional. Default: ignored, must be less than minReplicaCount
117
117
```
118
118
119
119
> 💡 **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.
This property specifies whether the target resource (`Deployment`, `StatefulSet`,...) should be scaled back to original replicas count, after the `ScaledObject` is deleted.
170
+
This property specifies whether the target resource (`Deployment`, `StatefulSet`,...) should be scaled back to original replicas count, after the `ScaledObject` is deleted.
171
171
Default behavior is to keep the replica count at the same number as it is in the moment of `ScaledObject's` deletion.
172
172
173
173
For example a `Deployment` with `3 replicas` is created, then `ScaledObject` is created and the `Deployment` is scaled by KEDA to `10 replicas`. Then `ScaledObject` is deleted:
@@ -201,6 +201,29 @@ Starting from Kubernetes v1.18 the autoscaling API allows scaling behavior to be
201
201
202
202
**Assumptions:** KEDA must be running on Kubernetes cluster v1.18+, in order to be able to benefit from this setting.
203
203
204
+
---
205
+
206
+
```yaml
207
+
advanced:
208
+
scalingModifiers: # Optional. Section to specify scaling modifiers
209
+
target: {target-value-to-scale-on} # Mandatory. New target if metrics are anyhow composed together
210
+
formula: {formula-for-fetched-metrics} # Mandatory. Formula for calculation
211
+
```
212
+
213
+
**`scalingModifiers`**
214
+
215
+
The `scalingModifiers` is optional and **experimental**. If defined, both `target` and `formula` are mandatory. Using this structure creates `composite-metric` for the HPA that will replace all requests for external metrics and handle them internally. With `scalingModifiers` each trigger used in the `formula` **must** have a name defined.
216
+
217
+
**`scalingModifiers.target`**
218
+
219
+
`target`defines new target value to scale on for the composed metric. All scaler metrics must be of the same type in order for ScaledObject to be successfully validated.
220
+
221
+
**`scalingModifiers.formula`**
222
+
223
+
`formula`composes metrics together and allows them to be modified/manipulated. It accepts mathematical/conditional statements using [this external project](https://github.com/antonmedv/expr). If the `fallback` scaling feature is in effect, the `formula` will NOT modify its metrics (therefore it modifies metrics only when all of their triggers are healthy). Complete language definition of `expr` package can be found [here](https://expr.medv.io/docs/Language-Definition). Formula must return a single value (not boolean).
224
+
225
+
For examples of this feature see section [Scaling Modifiers](#scaling-modifiers-experimental) below.
226
+
204
227
---
205
228
#### triggers
206
229
```yaml
@@ -245,6 +268,65 @@ metadata:
245
268
246
269
The presensce of this annotation will pause autoscaling no matter what number of replicas is provided. The above annotation will scale your current workload to 0 replicas and pause autoscaling. You can set the value of replicas for an object to be paused at to any arbitary number. To enable autoscaling again, simply remove the annotation from the `ScaledObject` definition.
Formula composes 2 given metrics from 2 triggers `kubernetes-workload` named `trig_one` and `metrics-api` named `trig_two` together as an average value and returns one final metric which is used to make autoscaling decisions on.
297
+
298
+
**Example: ternary operator**
299
+
300
+
```yaml
301
+
advanced:
302
+
scalingModifiers:
303
+
formula: "trig_one > 2 ? trig_one + trig_two : 1"
304
+
```
305
+
306
+
If metric value of trigger `trig_one` is more than 2, then return `trig_one` + `trig_two` otherwise return 1.
Conditions can be used within another condition as well.
327
+
If value of `trig_one` is less than 2 AND `trig_one`+`trig_two` is atleast 2 then return 5, if only the first is true return 10, if the first condition is false then return 0.
328
+
329
+
Complete language definition of `expr` package can be found [here](https://expr.medv.io/docs/Language-Definition). Formula must return a single value (not boolean)
248
330
### Activating and Scaling thresholds
249
331
250
332
To give a consistent solution to this problem, KEDA has 2 different phases during the autoscaling process.
0 commit comments