Skip to content

Commit a4f9f39

Browse files
authored
feat: Support aggregation options (kedacore#961)
* feat: Support aggregation options Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es> * Updates Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es> * Updates Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es> * fix changelog Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es> * style & codegen Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es> * add mocks Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es> * update docs Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es> * fix e2e test Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es> * merge issues Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es> * update manifests Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es> --------- Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
1 parent a8c1258 commit a4f9f39

40 files changed

+1482
-306
lines changed

CHANGELOG.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ This changelog keeps track of work items that have been completed and are ready
2424

2525
- **General**: Propagate HTTPScaledObject labels and annotations to ScaledObject ([#840](https://github.com/kedacore/http-add-on/issues/840))
2626
- **General**: Provide support to allow HTTP scaler to work alongside other core KEDA scalers ([#489](https://github.com/kedacore/http-add-on/issues/489))
27+
- **General**: Support aggregation windows ([#882](https://github.com/kedacore/http-add-on/issues/882))
2728

2829
### Improvements
2930

31+
- **General**: TODO ([#TODO](https://github.com/kedacore/http-add-on/issues/TODO))
32+
3033
### Fixes
3134

3235
- **General**: Ensure operator is aware about changes on underlying ScaledObject ([#900](https://github.com/kedacore/http-add-on/issues/900))
@@ -35,16 +38,13 @@ This changelog keeps track of work items that have been completed and are ready
3538

3639
You can find all deprecations in [this overview](https://github.com/kedacore/http-add-on/labels/breaking-change) and [join the discussion here](https://github.com/kedacore/http-add-on/discussions/categories/deprecations).
3740

38-
New deprecation(s):
39-
40-
41-
Previously announced deprecation(s):
42-
41+
- **General**: Deprecated `.spec.scaleTargetRef.deployment` ([#960](https://github.com/kedacore/http-add-on/discussions/960))
4342
- **General**: Deprecated `KEDA_HTTP_DEPLOYMENT_CACHE_POLLING_INTERVAL_MS` in favor of `KEDA_HTTP_ENDPOINTS_CACHE_POLLING_INTERVAL_MS` ([#438](https://github.com/kedacore/http-add-on/issues/438))
43+
- **General**: Deprecated `targetPendingRequests` in favor of `spec.scalingMetric.*.targetValue` ([#959](https://github.com/kedacore/http-add-on/discussions/959))
4444

4545
### Other
4646

47-
- **General**: TODO ([#TODO](https://github.com/kedacore/http-add-on/issues/TODO))
47+
- **General**: Unify loggers ([#958](https://github.com/kedacore/http-add-on/issues/958))
4848

4949
## v0.7.0
5050

RELEASE-PROCESS.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,17 @@ It should not include every single change but solely what matters to our custome
2020

2121
Add the new released version to the list in `KEDA Version` dropdown in [2_bug_report.yml](https://github.com/kedacore/http-add-on/blob/main/.github/ISSUE_TEMPLATE/2_bug_report.yml).
2222

23-
## 4: Create a new GitHub release
23+
## 4. Update documentation references to current version
24+
25+
Update the links to current version within the file `walkthrough.md`
26+
27+
> ```console
28+
> kubectl create -n $NAMESPACE -f examples/v0.7.0/httpscaledobject.yaml
29+
> ```
30+
31+
> >If you'd like to learn more about this object, please see the [`HTTPScaledObject` reference](THE REFERENCE).
32+
33+
## 5: Create a new GitHub release
2434
2535
[Create a new release](https://github.com/kedacore/http-add-on/releases/new) on the GitHub releases page, using your new release number.
2636
@@ -30,7 +40,7 @@ The release description should be a short to medium length summary of what has c
3040
3141
After you create the new release, automation in a GitHub action will build and deploy new container images.
3242
33-
## 5: Submit a PR to the [Helm Charts Repository](https://github.com/kedacore/charts)
43+
## 6: Submit a PR to the [Helm Charts Repository](https://github.com/kedacore/charts)
3444
3545
The scope of the changes you'll need to make to the Helm chart vary, but the below list is the minimum set of fields to change:
3646
@@ -66,11 +76,11 @@ Once you've made changes to the chart, here's how to do submit the change to the
6676

6777
After your PR is merged, you've completed the release. Congratulations! You can optionally write a blog post about it; see the next section if you're interested.
6878

69-
## 6: Publish release on Artifact Hub
79+
## 7: Publish release on Artifact Hub
7080

7181
Publish release on Artifact Hub by creating a new version in [kedacore/external-scalers](https://github.com/kedacore/external-scalers/tree/main/artifacthub/add-ons-http).
7282

73-
## 7: Write a blog post on the documentation site (_optional_)
83+
## 8: Write a blog post on the documentation site (_optional_)
7484

7585
If you believe that your release is large enough to warrant a blog post on the [keda.sh/blog](https://keda.sh/blog/) site, please go to [github.com/kedacore/keda-docs](https://github.com/kedacore/keda-docs) and submit a new PR with a blog article about the release.
7686

config/crd/bases/http.keda.sh_httpscaledobjects.yaml

+32-1
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,39 @@ spec:
121121
description: (optional) Cooldown period value
122122
format: int32
123123
type: integer
124+
scalingMetric:
125+
description: (optional) Configuration for the metric used for scaling
126+
properties:
127+
concurrency:
128+
description: Scaling based on concurrent requests for a given
129+
target
130+
properties:
131+
targetValue:
132+
default: 100
133+
description: Target value for rate scaling
134+
type: integer
135+
type: object
136+
requestRate:
137+
description: Scaling based the average rate during an specific
138+
time window for a given target
139+
properties:
140+
granularity:
141+
default: 1s
142+
description: Time granularity for rate calculation
143+
type: string
144+
targetValue:
145+
default: 100
146+
description: Target value for rate scaling
147+
type: integer
148+
window:
149+
default: 1m
150+
description: Time window for rate calculation
151+
type: string
152+
type: object
153+
type: object
124154
targetPendingRequests:
125-
description: (optional) Target metric value
155+
description: (optional) DEPRECATED (use SscalingMetric instead) Target
156+
metric value
126157
format: int32
127158
type: integer
128159
required:

docs/ref/v0.6.0/http_scaled_object.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The `HTTPScaledObject`
22

3-
>This document reflects the specification of the `HTTPScaledObject` resource for the `v0.7.0` version.
3+
>This document reflects the specification of the `HTTPScaledObject` resource for the `v0.6.0` version.
44
55
Each `HTTPScaledObject` looks approximately like the below:
66

docs/ref/v0.8.0/http_scaled_object.md

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# The `HTTPScaledObject`
2+
3+
>This document reflects the specification of the `HTTPScaledObject` resource for the `v0.8.0` version.
4+
5+
Each `HTTPScaledObject` looks approximately like the below:
6+
7+
```yaml
8+
kind: HTTPScaledObject
9+
apiVersion: http.keda.sh/v1alpha1
10+
metadata:
11+
name: xkcd
12+
spec:
13+
hosts:
14+
- myhost.com
15+
pathPrefixes:
16+
- /test
17+
scaleTargetRef:
18+
name: xkcd
19+
kind: Deployment
20+
apiVersion: apps/v1
21+
service: xkcd
22+
port: 8080
23+
replicas:
24+
min: 5
25+
max: 10
26+
scaledownPeriod: 300
27+
scalingMetric: # requestRate and concurrency are mutually exclusive
28+
requestRate:
29+
granularity: 1s
30+
targetValue: 100
31+
window: 1m
32+
concurrency:
33+
targetValue: 100
34+
```
35+
36+
This document is a narrated reference guide for the `HTTPScaledObject`, and we'll focus on the `spec` field.
37+
38+
## `hosts`
39+
40+
These are the hosts to apply this scaling rule to. All incoming requests with one of these values in their `Host` header will be forwarded to the `Service` and port specified in the below `scaleTargetRef`, and that same `scaleTargetRef`'s workload will be scaled accordingly.
41+
42+
## `pathPrefixes`
43+
44+
>Default: "/"
45+
46+
These are the paths to apply this scaling rule to. All incoming requests with one of these values as path prefix will be forwarded to the `Service` and port specified in the below `scaleTargetRef`, and that same `scaleTargetRef`'s workload will be scaled accordingly.
47+
48+
## `scaleTargetRef`
49+
50+
This is the primary and most important part of the `spec` because it describes:
51+
52+
1. The incoming host to apply this scaling rule to.
53+
2. What workload to scale.
54+
3. The service to which to route HTTP traffic.
55+
56+
### `deployment` (DEPRECTATED: removed as part of v0.9.0)
57+
58+
This is the name of the `Deployment` to scale. It must exist in the same namespace as this `HTTPScaledObject` and shouldn't be managed by any other autoscaling system. This means that there should not be any `ScaledObject` already created for this `Deployment`. The HTTP Add-on will manage a `ScaledObject` internally.
59+
60+
### `name`
61+
62+
This is the name of the workload to scale. It must exist in the same namespace as this `HTTPScaledObject` and shouldn't be managed by any other autoscaling system. This means that there should not be any `ScaledObject` already created for this workload. The HTTP Add-on will manage a `ScaledObject` internally.
63+
64+
### `kind`
65+
66+
This is the kind of the workload to scale.
67+
68+
### `apiVersion`
69+
70+
This is the apiVersion of the workload to scale.
71+
72+
### `service`
73+
74+
This is the name of the service to route traffic to. The add-on will create autoscaling and routing components that route to this `Service`. It must exist in the same namespace as this `HTTPScaledObject` and should route to the same `Deployment` as you entered in the `deployment` field.
75+
76+
### `port`
77+
78+
This is the port to route to on the service that you specified in the `service` field. It should be exposed on the service and should route to a valid `containerPort` on the `Deployment` you gave in the `deployment` field.
79+
80+
### `targetPendingRequests` (DEPRECTATED: removed as part of v0.9.0)
81+
82+
>Default: 100
83+
84+
This is the number of _pending_ (or in-progress) requests that your application needs to have before the HTTP Add-on will scale it. Conversely, if your application has below this number of pending requests, the HTTP add-on will scale it down.
85+
86+
For example, if you set this field to 100, the HTTP Add-on will scale your app up if it sees that there are 200 in-progress requests. On the other hand, it will scale down if it sees that there are only 20 in-progress requests. Note that it will _never_ scale your app to zero replicas unless there are _no_ requests in-progress. Even if you set this value to a very high number and only have a single in-progress request, your app will still have one replica.
87+
88+
### `scaledownPeriod`
89+
90+
>Default: 300
91+
92+
The period to wait after the last reported active before scaling the resource back to 0.
93+
94+
> Note: This time is measured on KEDA side based on in-flight requests, so workloads with few and random traffic could have unexpected scale to 0 cases. In those case we recommend to extend this period to ensure it doesn't happen.
95+
96+
97+
## `scalingMetric`
98+
99+
This is the second most important part of the `spec` because it describes how the workload has to scale. This section contains 2 nested sections (`requestRate` and `concurrency`) which are mutually exclusive between themselves.
100+
101+
### `requestRate`
102+
103+
This section enables scaling based on the request rate.
104+
105+
> **NOTE**: Requests information is stored in memory, aggragating long periods (longer than 5 minutes) or too fine granularity (less than 1 second) could produce perfomance issues or memory usage increase.
106+
107+
> **NOTE 2**: Although updating `window` and/or `granularity` is something doable, the process just replaces all the stored request count infomation. This can produce unexpected scaling behaviours until the window is populated again.
108+
109+
#### `targetValue`
110+
111+
>Default: 100
112+
113+
This is the target value for the scaling configuration.
114+
115+
#### `window`
116+
117+
>Default: "1m"
118+
119+
This value defines the aggregation window for the request rate calculation.
120+
121+
#### `granularity`
122+
123+
>Default: "1s"
124+
125+
This value defines the granualarity of the aggregated requests for the request rate calculation.
126+
127+
### `concurrency`
128+
129+
This section enables scaling based on the request concurrency.
130+
131+
> **NOTE**: This is the only scaling behaviour before v0.8.0
132+
133+
#### `targetValue`
134+
135+
>Default: 100
136+
137+
This is the target value for the scaling configuration.

docs/walkthrough.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ For scenerios where you want to integrate HTTP Add-On scaler with other keda sca
9595

9696
> 💡 Ensure that your ScaledObject is created with a different name than the `HTTPScaledObject` to ensure your ScaledObject is not removed by the reconciler.
9797
98-
It is reccomended that you first deploy your HTTPScaledObject with no annotation set in order to obtain the latest trigger spec to use on your own managed ScaledObject.
98+
If you don't know how to set the external scaler in the ScaledObject, you can deploy first your HTTPScaledObject with no annotation set in order to obtain the latest trigger spec to use on your own managed ScaledObject.
9999

100100
1. Deploy your `HTTPScaledObject` with annotation set to false
101101

@@ -112,8 +112,7 @@ For example:
112112
triggers:
113113
- type: external-push
114114
metadata:
115-
hosts: example-service
116-
pathPrefixes: ""
115+
httpScaledObject: YOUR_HTTPSCALEDOBJECT_NAME
117116
scalerAddress: keda-http-add-on-external-scaler.keda:9090
118117
```
119118

go.mod

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,21 @@ go 1.21
44

55
require (
66
github.com/go-logr/logr v1.4.1
7-
github.com/go-logr/zapr v1.3.0
87
github.com/golang/mock v1.7.0-rc.1.0.20220812172401-5b455625bd2c
8+
github.com/google/go-cmp v0.6.0
99
github.com/hashicorp/go-immutable-radix/v2 v2.1.0
1010
github.com/kedacore/keda/v2 v2.13.0
1111
github.com/kelseyhightower/envconfig v1.4.0
1212
github.com/onsi/ginkgo/v2 v2.17.1
1313
github.com/onsi/gomega v1.31.0
1414
github.com/stretchr/testify v1.8.4
15-
go.uber.org/zap v1.26.0
1615
golang.org/x/sync v0.6.0
1716
google.golang.org/grpc v1.61.0
1817
google.golang.org/protobuf v1.33.0
1918
k8s.io/api v0.29.0
2019
k8s.io/apimachinery v0.29.0
2120
k8s.io/client-go v0.29.0
22-
k8s.io/code-generator v0.29.0
21+
k8s.io/code-generator v0.29.3
2322
k8s.io/utils v0.0.0-20240102154912-e7106e64919e
2423
sigs.k8s.io/controller-runtime v0.17.1
2524
sigs.k8s.io/kustomize/kustomize/v5 v5.3.0
@@ -35,15 +34,15 @@ require (
3534
github.com/expr-lang/expr v1.15.8 // indirect
3635
github.com/fsnotify/fsnotify v1.7.0 // indirect
3736
github.com/go-errors/errors v1.5.1 // indirect
37+
github.com/go-logr/zapr v1.3.0 // indirect
3838
github.com/go-openapi/jsonpointer v0.20.2 // indirect
3939
github.com/go-openapi/jsonreference v0.20.4 // indirect
4040
github.com/go-openapi/swag v0.22.7 // indirect
4141
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
4242
github.com/gogo/protobuf v1.3.2 // indirect
4343
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
44-
github.com/golang/protobuf v1.5.3 // indirect
44+
github.com/golang/protobuf v1.5.4 // indirect
4545
github.com/google/gnostic-models v0.6.8 // indirect
46-
github.com/google/go-cmp v0.6.0 // indirect
4746
github.com/google/gofuzz v1.2.0 // indirect
4847
github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42 // indirect
4948
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
@@ -72,6 +71,7 @@ require (
7271
github.com/xlab/treeprint v1.2.0 // indirect
7372
go.starlark.net v0.0.0-20231121155337-90ade8b19d09 // indirect
7473
go.uber.org/multierr v1.11.0 // indirect
74+
go.uber.org/zap v1.26.0 // indirect
7575
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 // indirect
7676
golang.org/x/mod v0.14.0 // indirect
7777
golang.org/x/net v0.20.0 // indirect

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ github.com/golang/mock v1.7.0-rc.1.0.20220812172401-5b455625bd2c h1:8AzxBXzXPCzl
4242
github.com/golang/mock v1.7.0-rc.1.0.20220812172401-5b455625bd2c/go.mod h1:s42URUywIqd+OcERslBJvOjepvNymP31m3q8d/GkuRs=
4343
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
4444
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
45-
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
46-
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
45+
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
46+
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
4747
github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I=
4848
github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U=
4949
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
@@ -254,8 +254,8 @@ k8s.io/apimachinery v0.29.0 h1:+ACVktwyicPz0oc6MTMLwa2Pw3ouLAfAon1wPLtG48o=
254254
k8s.io/apimachinery v0.29.0/go.mod h1:eVBxQ/cwiJxH58eK/jd/vAk4mrxmVlnpBH5J2GbMeis=
255255
k8s.io/client-go v0.29.0 h1:KmlDtFcrdUzOYrBhXHgKw5ycWzc3ryPX5mQe0SkG3y8=
256256
k8s.io/client-go v0.29.0/go.mod h1:yLkXH4HKMAywcrD82KMSmfYg2DlE8mepPR4JGSo5n38=
257-
k8s.io/code-generator v0.29.0 h1:2LQfayGDhaIlaamXjIjEQlCMy4JNCH9lrzas4DNW1GQ=
258-
k8s.io/code-generator v0.29.0/go.mod h1:5bqIZoCxs2zTRKMWNYqyQWW/bajc+ah4rh0tMY8zdGA=
257+
k8s.io/code-generator v0.29.3 h1:m7E25/t9R9NvejspO2zBdyu+/Gl0Z5m7dCRc680KS14=
258+
k8s.io/code-generator v0.29.3/go.mod h1:x47ofBhN4gxYFcxeKA1PYXeaPreAGaDN85Y/lNUsPoM=
259259
k8s.io/component-base v0.29.0 h1:T7rjd5wvLnPBV1vC4zWd/iWRbV8Mdxs+nGaoaFzGw3s=
260260
k8s.io/component-base v0.29.0/go.mod h1:sADonFTQ9Zc9yFLghpDpmNXEdHyQmFIGbiuZbqAXQ1M=
261261
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 h1:pWEwq4Asjm4vjW7vcsmijwBhOr1/shsbSYiWXmNGlks=

0 commit comments

Comments
 (0)