99 Commits

Author SHA1 Message Date
Lucas Thiesen
cd986058e4
Delete unwanted comments
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:38 +02:00
Lucas Thiesen
b8532b756b
Update HPA to autoscaling/v2 in new collectors
Reference links: https://github.com/zalando-incubator/kube-metrics-adapter/pull/551

Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:37 +02:00
Lucas Thiesen
f28653de74
Use regexp.Compile to avoid performance problems
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:37 +02:00
Lucas Thiesen
2f5d3f5a42
Change hostname collector type to requests-per-second
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:37 +02:00
Lucas Thiesen
153d754353
Add support for traffic weight specification
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:37 +02:00
Lucas Thiesen
02ec2282ab
Add multi hostname per metric support
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:37 +02:00
Lucas Thiesen
aa7b64e637
Add hostname RPS metric collector
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:36 +02:00
Lucas Thiesen
7633ac551e
Extract fake controller to use it in other tests
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:36 +02:00
Alexander Didenko
c4a1e08fdf
Update HPA to autoscaling/v2 apiVersion (#551) 2023-05-03 23:01:19 +02:00
Mikkel Oscar Lyderik Larsen
e2a922f110 Move generic functions to controller package
Move defaultTimeZone to a flag.

Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2023-04-06 17:53:17 +02:00
zlawrence
c60253e90c
add test for end date in incorrect format
Signed-off-by: zlawrence <zak.lawrence@zalando.de>
2022-12-21 14:08:44 +01:00
zlawrence
680e0feea1
fix nil pointer dereference
Signed-off-by: zlawrence <zak.lawrence@zalando.de>
2022-12-21 14:08:41 +01:00
zlawrence
8ba4d19c35
Add end date support for Repeating schedule. Added tests 2022-12-13 12:53:05 +01:00
zlawrence
37bf73c7fe
Add end date support for OneTime schedule 2022-12-12 20:02:15 +01:00
Mikkel Oscar Lyderik Larsen
55ce2d8c3d Update dependencies
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2022-09-13 23:21:39 +02:00
Katyanna Moura
5926f1aea1 Limit ingress support to only networking.k8s.io/v1
Given the deprecation of extensions/v1beta1, remove it from Ingress possibilities.

Signed-off-by: Katyanna Moura <amelie.kn@gmail.com>
2022-06-21 12:46:08 +02:00
Jonathan Juares Beber
1c9038b2cc
Merge pull request #374 from zalando-incubator/configurable-buckets
Make the number of ramp steps configurable
2021-10-25 10:21:32 +02:00
Jonathan Juares Beber
fd4ead837e
Make the number of ramp steps configurable
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>
2021-10-22 15:35:11 +02:00
Mikkel Oscar Lyderik Larsen
4acdf72ef7
Handle more complex array in json path
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2021-10-14 09:34:15 +02:00
Jonathan Juares Beber
8fe330941a
Use 10 buckets on ScalingSchedule ramp-up/down
The HPA has a feature to do not scale up and down when the change in the
metric is less than 10%:

> We'll skip scaling if the ratio is sufficiently close to 1.0 (within a
> globally-configurable tolerance, from the
> `--horizontal-pod-autoscaler-tolerance` flag, which defaults to 0.1.

It could lead to pods scaling up to 10% less than the target for
ScalingSchedules and then not scaling to the actual value if the metric
calculated before was less than 10% of the target.

This commit uses 10 fixed buckets for scaling, this way we know the
metric returned during a scaling event is at least 10% more than a
previous one calculated during the period of ramp up. The same is valid
for the scaling down during a ramp-down

Signed-off-by: Jonathan Juares Beber <jonathanbeber@gmail.com>
2021-09-30 19:01:59 +02:00
Alexey Ermakov
c5411c74b7 Scheduled scaling: add an optional scaling window
Signed-off-by: Alexey Ermakov <alexey.ermakov@zalando.de>
2021-09-24 15:33:49 +02:00
Mikkel Oscar Lyderik Larsen
318d47e05e
Add deprecation comment
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2021-08-20 09:33:18 +02:00
Mikkel Oscar Lyderik Larsen
190f0db092
Use labels for specifying Ingress/RouteGroup backend
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2021-08-20 09:33:17 +02:00
Mikkel Oscar Lyderik Larsen
c618494177
return early if backendName is empty
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2021-08-20 09:32:48 +02:00
Mikkel Oscar Lyderik Larsen
a08860d06c
rename function
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2021-08-20 09:22:06 +02:00
Mikkel Oscar Lyderik Larsen
6b0afe5180
Add support for scaling based on RouteGroup resource
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2021-08-19 18:28:58 +02:00
Jonathan Juares Beber
0ad7296d56
Switch Schedule optional fields to pointers
The `Date` and `Period` fields inside the `Schedule` type of the
`[Cluster]ScalingSchedule` CRDs are optional, but in its current
configuration the generated clients can't update or create these
resources since the empty fields do not pass the validation.

This commit updates the `[Cluster]ScalingSchedule.Schedule[*]` `Date`
and `Period` field to pointers, this way a null value is not validated
and the clients are able to update and create resources. It also updates
the collector code and tests to reflect the change.

Signed-off-by: Jonathan Juares Beber <jonathanbeber@gmail.com>
2021-06-30 17:09:48 +02:00
Jonathan Juares Beber
d7f9664d52
Remove HTTP collector check on identifier label
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>
2021-06-01 12:33:32 +02:00
Sandor Szücs
64a6b85c73
fix typo Saturday
Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
2021-05-26 12:03:07 +02:00
Jonathan Juares Beber
e6a04531fb
Merge pull request #326 from zalando-incubator/ignore-container-resource-metrics
Ignore ContainerResource metrics
2021-05-25 17:03:27 +02:00
Mikkel Oscar Lyderik Larsen
7289e6f8e2
Ignore ContainerResource metrics
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2021-05-25 16:45:35 +02:00
Jonathan Juares Beber
a382dbfe7b
Create ScalingSchedule collector
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>
2021-05-21 14:29:11 +02:00
Anatolii Dutchak
e16bacb24e Changed message text and level
Signed-off-by: Anatolii Dutchak <adutchak-x@tunein.com>
2021-05-05 11:22:51 +03:00
Anatolii Dutchak
52bfbbb1b0 Goimported pod_collector_test.go
Signed-off-by: Anatolii Dutchak <adutchak-x@tunein.com>
2021-04-30 18:08:30 +03:00
Anatolii Dutchak
cf5872ef08 Fixed formatting
Signed-off-by: Anatolii Dutchak <adutchak-x@tunein.com>
2021-04-30 18:00:23 +03:00
Anatolii Dutchak
b5432fb1f3 Fixed formatting
Signed-off-by: Anatolii Dutchak <adutchak-x@tunein.com>
2021-04-30 17:58:44 +03:00
Anatolii Dutchak
5466badd90 Added pod.DeletionTimestamp condition check
Signed-off-by: Anatolii Dutchak <adutchak-x@tunein.com>
2021-04-30 16:04:32 +03:00
Anatolii Dutchak
ea4a651afe Fixed tests
Signed-off-by: Anatolii Dutchak <adutchak-x@tunein.com>
2021-04-21 18:37:16 +03:00
Anatolii Dutchak
721c6553d8 Added conditions[i].Status == corev1.ConditionTrue check
Signed-off-by: Anatolii Dutchak <adutchak-x@tunein.com>
2021-04-21 18:25:49 +03:00
Anatolii Dutchak
5aa2272e37 Removed debug message, changed podReadyAge >= c.minPodReadyAge
Signed-off-by: Anatolii Dutchak <adutchak-x@tunein.com>
2021-04-20 12:33:47 +03:00
Anatolii Dutchak
b9300d1e46 Added namespace to logs, simplified GetPodReadyAge method
Signed-off-by: Anatolii Dutchak <adutchak-x@tunein.com>
2021-04-20 11:21:24 +03:00
Anatolii Dutchak
5747b6c9de Renamed min-pod-age to min-pod-ready-age. Considering LastTransitionTime for pod ready age.
Signed-off-by: Anatolii Dutchak <adutchak-x@tunein.com>
2021-04-19 18:51:39 +03:00
Anatolii Dutchak
6d15a1635a goimported pkg/collector/pod_collector_test.go
Signed-off-by: Anatolii Dutchak <adutchak-x@tunein.com>
2021-04-17 08:17:59 +03:00
Anatolii Dutchak
1f56abf931 Corrected formatting
Signed-off-by: Anatolii Dutchak <adutchak-x@tunein.com>
2021-04-17 00:52:00 +03:00
Anatolii Dutchak
f216070630 Introduced min-pod-age configuration key. Added Pod condition handling
Signed-off-by: Anatolii Dutchak <adutchak-x@tunein.com>
2021-04-17 00:52:00 +03:00
adutchak-x
adf0792079 Update pkg/collector/collector.go
Co-authored-by: Jonathan Juares Beber <jonathanbeber@gmail.com>
Signed-off-by: Anatolii Dutchak <adutchak-x@tunein.com>
2021-04-14 22:25:23 +03:00
Anatolii Dutchak
188cc91574 Reverted error check to errors.Is(), implemented Is() method for PluginNotFoundError
Signed-off-by: Anatolii Dutchak <adutchak-x@tunein.com>
2021-04-14 22:25:23 +03:00
Mikkel Oscar Lyderik Larsen
b7aa886546
Namespace external metrics (#259)
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2021-02-19 11:11:29 +01:00
Mikkel Oscar Lyderik Larsen
d55a551bd8
Don't check for metric name on AWS init
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2021-01-05 11:52:44 +01:00
Mikkel Oscar Lyderik Larsen
4506701b7c
Fix mapping of Prometheus query for new metric configuration
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2020-11-16 17:44:06 +01:00