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 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>
NewSession is being deprecated, NewSessionWithConfig handles things
such as role arns. This fixes permissions issues for users using
role arns for service accounts.
Signed-off-by: Ewan Valentine <ewan.valentine89@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>
* This commit adds a --disregard-incompatible-hpas that makes the HPA
provider stop erroring out when a collector cannot be created for a
metric in a HPA. Useful when kube-metrics-adapter runs alongside another
metrics provider. Fixes issue #94.
Signed-off-by: Tomás Pinho <me@tomaspinho.com>
* Make tests pass
Signed-off-by: Tomás Pinho <me@tomaspinho.com>
* Wraps the Plugin Not Found error in a new type that can be checked by the caller of a function to determine if its contents should be logged or added as an event to the HPA, when this HPA is incompatible.
The disregardIncompatibleHPAs is now targetting only the log or addition of the same event.
Signed-off-by: Tomás Pinho <me@tomaspinho.com>
* Invert if expression to select when we should log
CreateNewMetricsCollector errors: don't log when both conditions are true - it's not a PluginNotFoundError
and disregardIncompatibleHPAs flag is set to true. This way, if an error
is NOT PluginNotFoundError it will always be logged, and when it IS
PluginNotFoundError it will only be logged when
disregardIncompatibleHPAs is false.
Signed-off-by: Tomás Pinho <me@tomaspinho.com>
* Remove redundant "whether to"
Signed-off-by: Tomás Pinho <me@tomaspinho.com>
* Add test case for updating HPAs via HPA Provider while disregarding
incompatible HPAs.
Signed-off-by: Tomás Pinho <me@tomaspinho.com>
* 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>
* feat: expose basic go metrics via prometheus
Signed-off-by: Martin Linkhorst <martin.linkhorst@zalando.de>
* feat: expose basic counter of successful and failed collections and updates
Signed-off-by: Martin Linkhorst <martin.linkhorst@zalando.de>