I am working on a project where we want to test an autoscaling algorithm which involves making a few changes to the default horizontal pod autoscaling algorithm on Kubernetes. Where should we make changes in the https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler repo so that we can test our algorithm?
The Cluster-Autoscaler is pretty much a cluster auto scaling version which will scale the number of Nodes, in case any of below happens.
- there are pods that failed to run in the cluster due to insufficient resources
- there are nodes in the cluster that have been underutilized for an extended period of time and their pods can be placed on other existing nodes.
If you want a custom pod scaling algorithm, I would recommend doing it as a simple service that does just that and not to alter the Cluster Autoscaler. Here's a similar solution to your problem.
https://stackoverflow.com/a/58447811/5617140
You can alter the service logic to suit your requirements. And it is probably a good idea to use Kubernetes API to achieve scaling tasks.