addon-resizer/enhancements/5546-scaling-based-on-container-count/README.md
Currently Addon Resizer supports scaling based on the number of nodes. Some workloads use resources proportionally to the number of containers in the cluster. Since number of containers per node is very different in different clusters it's more resource-efficient to scale such workloads based directly on the container count.
master branch of Addon Resizer.Add flag --scaling-mode to Addon Resizer on the addon-resizer-release-1.8 branch. Flag will
have two valid values:
node-proportional - default, current behavior.container-proportional - addon resizer will set resources, using the same algorithm it's using now but using number
of containers where it's currently using number of nodes.Addon Resizer 1.8 assumes in multiple places that it's scaling based on the number of nodes:
--extra-cpu, --extra-memory, --extra-storage, and
--minClusterSize) will need to be updated to instead refer to cluster size.--scaling-mode flag.In addition to implementing the feature we should also clean up the code and documentation.
One potential risk is that Addon resizer can obtain cluster size (node count or container count):
depending on the configuration. There can be many times more containers in a cluster that there are nodes. So listing all containers could result in higher load on the Cluster API server. Since Addon Resizer is requesting very few fields I don't expect this effect to be noticeable.
Also I expect metrics-server to test for this before using the feature and any other users of Addon Resizer are likely better off using metrics (which don't have this problem).
kubernetesClient.CountContainers(). It will be analogous to the existing
kubernetesClient.CountNodes() function.
/pods URI instead of /nodes).containers field).Spec.InitContainers, Spec.Containers, and Spec.EphemeralContainers fields.--scaling-mode flag, with two valid values:
node-proportional - default, current behavior, scaling based on clusters node count andcontainer-proportional - new behavior, scaling based on clusters container countupdateResources() function.updateResources() use node count or container count, depending on the value.Check that listing containers directly works
Coinsider listing pods, getting containers only for working pods
In addition to unit tests we will run manual e2e test:
example.yaml but scaling the deployment based on the number of containers in the cluster.pause containers.Test the feature by:
pause containers.Test the node-based scaling:
example.yaml.Both tests should be performed with metrics- and API- based scaling.