This project is supported by:
Predictive Horizontal Pod Autoscaler
This is a Custom Pod Autoscaler; aiming to have identical functionality to the Horizontal Pod Autoscaler, however with added predictive elements using statistical models.
This uses the Horizontal Pod Autoscaler Custom Pod Autoscaler extensively to provide most functionality for the Horizontal Pod Autoscaler parts.
Why would I use it?
This autoscaler lets you choose models and fine tune them in order to predict how many replicas a resource should have, preempting events such as regular, repeated high load.
- Functionally identical to Horizontal Pod Autoscaler for calculating replica counts without prediction.
- Choice of statistical models to apply over Horizontal Pod Autoscaler replica counting logic.
- Holt-Winters Smoothing
- Linear Regression
- Allows customisation of Kubernetes autoscaling options without master node access. Can therefore work on managed
solutions such as EKS or GCP.
- CPU Initialization Period.
- Downscale Stabilization.
- Sync Period.
- Initial Readiness Delay.
- Runs in Kubernetes as a standard Pod.
How does it work?
This project works by calculating the number of replicas a resource should have, then storing these values and using statistical models against them to produce predictions for the future. These predictions are compared and can be used instead of the raw replica count calculated by the Horizontal Pod Autoscaler logic.
examples/ directory for working code samples.
Developing this project
Developing this project requires these dependencies:
Any Python dependencies must be installed by running:
pip install -r requirements-dev.txt
To view docs locally you need some Python dependencies, run:
pip install -r docs/requirements.txt
It is recommended to test locally using a local Kubernetes managment system, such as k3d (allows running a small Kubernetes cluster locally using Docker).
Once you have a cluster available, you should install the Custom Pod Autoscaler Operator (CPAO) onto the cluster to let you install the PHPA.
With the CPAO installed you can install your development builds of the PHPA onto the cluster by building the image
locally, and then pushing the image to the K8s cluster's registry (to do that with k3d you can use the
k3d image import command).
Finally you can deploy a PHPA example (see the
examples/ directory for choices) to test your changes.
Note that the examples generally use
ImagePullPolicy: Always, you may need to change this to
ImagePullPolicy: IfNotPresentto use your local build.
make vendor_modules- generates a vendor folder.
make- builds the Predictive HPA binary.
make docker- builds the Predictive HPA image.
make lint- lints the code.
make beautify- beautifies the code, must be run to pass the CI.
make unittest- runs the unit tests.
make doc- hosts the documentation locally, at
make view_coverage- opens up any generated coverage reports in the browser.