PHPA takes metrics from our InfluxDB and Graphite and then scales a deployment based on those metrics.
Before building PHPA, we actually looked at Horizontal Pod Autoscaler but we found that it only scales based on CPU and Memory usage whereas our needs were different. We wanted to scale based on metrics present in our monitoring systems (Graphite and InfluxDB). After looking into custom metrics for HPA, we figured out that it was very complicated, was mostly tied to Prometheus, didn't have great support for Graphite, and also required knowledge of GoLang.
Also during the time, Knative was released. After looking into it, we figured out that it was still in alpha and required running multiple components, which would eventually result in operational complexity.
Hence, we decided to build PHPA.
Read more on how we built PHPA on our blog: Introducing PHPA: Our Kubernetes Horizontal Pod Autoscaler
- Setup
phpa-service-account
using setup-access.yaml - Check for service account
kubectl get serviceaccount phpa-service-account
At Clarisights, we run PHPA as a Kubernetes deployment in same cluster as the deployment PHPA is auto-scaling. You can even run it as a Kubernetes CronJob.
- Build Docker image
docker build -t phpa:latest https://github.com/clarisights/phpa.git
- Push Docker image to your container registry
- Create config map from file with your PHPA config files
kubectl create configmap phpa-configs --from-file <configs_dir>/ --dry-run -o yaml
- Mount config map in your PHPA cronjob/deployment
- Deploy
Look in examples folder for example configs and deployment files.
Clarisights uses GitHub to manage reviews of pull requests.
PHPA is written in Ruby. You need to install Ruby and Bundler - check Dockerfile for the instructions.
- Fork this repo
- Create a branch and add your features
- Send your Pull Requests and tag contributors for review
We use Rspec for testing.
- Create an issue and tag contributors
Eventually, we would want to migrate PHPA to a Custom Kubernetes Controller and use Kubernetes CRD (CustomResourceDefinition) for PHPAConfig. Along with that having support for more metric server adaptors would be nice to have as well.