In #371 we introduced steps to make the scaling up possible even when
the HPA forces a 10% change. The problem is that 10% might not be
sufficient for some specific scaling scenarios.
For example, a an application targeting 12 pods and using a
ScalingSchedule with the value of 10000 to achieve that, will require a
target of 833. With 10 ramp steps the 90% bucket will return a metric of
9000 and the HPA calculates (9000/833) 10.8 pods, rounding to 11 pods.
Once the metric reaches the time to return 100% it will won't be
effective, since the change of the current number of pods (11) and the
desired one (12) is less than 10%.
This commit does not try to tackle this problem completely, since the
10% rule is not fixed, might change among different clusters and is also
dependent on the value given to each ScalingSchedule. Therefore, this
commit makes the number of ramp steps configurable via the
`--scaling-schedule-ramp-steps` config flag, defaulting to 10.
Signed-off-by: Jonathan Juares Beber <jonathanbeber@gmail.com>
This commit removes the logic that checks for an identifier label in the
http collector config. It also removes the documentation on the README
that mentions that the metric has to be in an old format, removed in
the #219.
Fixes#331
Signed-off-by: Jonathan Juares Beber <jonathanbeber@gmail.com>
This commit adds two new collectors to the adapter:
- ClusterScalingScheduleCollector; and
- ScalingScheduleCollector
Also, it introduces the required collectors plugins, initialization
logic in the server startup, documentation and deployment example
(including the helm chart). A new config flag is created,
`-scaling-schedule`, and allows to enable and to disable the collection
of such metrics. It's disabled by default.
This collectors are the required logic to utilise the CRDs introduced in
the #284 pull request. It makes use of the kubernetes go-client
implementations of a [Store][0] and [Reflector][1].
[0]: https://pkg.go.dev/k8s.io/client-go/tools/cache#Store
[1]: https://pkg.go.dev/k8s.io/client-go/tools/cache#Reflector
Signed-off-by: Jonathan Juares Beber <jonathanbeber@gmail.com>
* Use labels for mapping metric types to metrics
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
* Log warning when old format is used
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
* Test NewCollector logic for external metrics
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
Allow configuration per metric for connect and request timeouts
when querying pods for JSON metrics.
Signed-off-by: Abe Friesen <2319792+doyshinda@users.noreply.github.com>
Adds a new metric-config option named `rawQuery`. The value of
this option will be appended to the metric `path` as URL query
parameters to be used by the pod's application. E.g.,:
```
metric-config.pods.requests-per-second.json-path/rawQuery: "foo=bar&baz=bop"
```
will apppend `?foo=bar&baz=bop` to the URL.
Signed-off-by: Abe Friesen <2319792+doyshinda@users.noreply.github.com>
* This is the initial implementation of support for JSONPath expressions
that return arrays of values instead of a single value.
This extends the
collector to define a few handy reducer functions that take in the slice
of float64 and return a single value. It also allows the user to define
which reducer function to use via the
"metric-config.<metricType>.<metricName>.json-path/reducer-func"
annotation, which
can have the values of 'avg', 'min', 'max' and 'sum'.
For instance, the Ruby puma webserver exposes metrics of the form of $.worker_status[*].last_status.pool_capacity that have to be consumed as an array of values to be properly targetted.
Signed-off-by: Tomás Pinho <me@tomaspinho.com>
* Renames "reducerFunc" to "aggregator" for consistency with other
collectors. Renames the annotation from
"metric-config.<metricType>.<metricName>.json-path/reducer-func" to "metric-config.<metricType>.<metricName>.json-path/aggregator".
Signed-off-by: Tomás Pinho <me@tomaspinho.com>
* Return error instead of defaulting to the avg aggregator, when no valid
aggregator name was specified and the JSONPath value is a slice of
numbers.
Signed-off-by: Tomás Pinho <me@tomaspinho.com>
* Fix index out of range on initialized output slice that was found while
writing tests.
Signed-off-by: Tomás Pinho <me@tomaspinho.com>
* Add tests for all added functions + NewJSONPathMetricsGetter
Signed-off-by: Tomás Pinho <me@tomaspinho.com>
* Add documentation on the `aggregator` option.
Signed-off-by: Tomás Pinho <me@tomaspinho.com>
* reducer function -> aggregator function
Signed-off-by: Tomás Pinho <me@tomaspinho.com>
* Fix comment to account for returned error.
Signed-off-by: Tomás Pinho <me@tomaspinho.com>
This adds support for `averageValue` for the `request-per-second` metric
based on Ingress Objects. This is only supported from Kubernetes
`>=v1.14` (https://github.com/kubernetes/kubernetes/pull/72872).
When defining the HPA with `autoscaling/v2beta1` you still need to
define `targetValue` even though it won't be used when `averageValue` is
set. Once we default to `autoscaling/v2beta2` this akward API will be
gone.
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
* Added weighting of rps metrics based on backend weights
Signed-off-by: Arjun Naik <arjun.rn@gmail.com>
* Updated documented with instructions on how to use the backend weighting
Signed-off-by: Arjun Naik <arjun.rn@gmail.com>
* Changed separator for RPS metric and added flag to specify backend weights annotation.
Signed-off-by: Arjun Naik <arjun.rn@gmail.com>
* Allow for multiple backends with for weighting.
Signed-off-by: Arjun Naik <arjun.rn@gmail.com>
* Adding test coverage through coverall
Adding test coverage through coverall so we can see the current state of
test coverage
Signed-off-by: Muhammad Muaaz Saleem <muhammad.muaaz.saleem@zalando.de>
* Fix go.sum for go 1.11.2
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
* Trying to make travis use go 1.11.2
Since go.mod and go.sum files don't seem to be compatible between
go1.11.1, trying to make travis use go 1.11.2
Signed-off-by: Muhammad Muaaz Saleem <muhammad.muaaz.saleem@zalando.de>