{"id":21514537,"url":"https://github.com/jthomperoo/predictive-horizontal-pod-autoscaler","last_synced_at":"2025-04-06T18:17:02.798Z","repository":{"id":36632143,"uuid":"226749712","full_name":"jthomperoo/predictive-horizontal-pod-autoscaler","owner":"jthomperoo","description":"Horizontal Pod Autoscaler built with predictive abilities using statistical models","archived":false,"fork":false,"pushed_at":"2023-10-11T23:24:48.000Z","size":448,"stargazers_count":341,"open_issues_count":4,"forks_count":29,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-30T17:09:13.719Z","etag":null,"topics":["autoscaler","autoscaling","go","golang","horizontal-pod-autoscaler","kubernetes","operator","operator-framework","operator-sdk","predictions","predictive-analytics","python","replicas","statistical-models","statsmodels"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jthomperoo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-08T23:55:40.000Z","updated_at":"2025-03-16T09:57:01.000Z","dependencies_parsed_at":"2024-06-18T21:32:00.904Z","dependency_job_id":"d60f076b-07fc-4b37-a138-b6788b288ee4","html_url":"https://github.com/jthomperoo/predictive-horizontal-pod-autoscaler","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jthomperoo%2Fpredictive-horizontal-pod-autoscaler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jthomperoo%2Fpredictive-horizontal-pod-autoscaler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jthomperoo%2Fpredictive-horizontal-pod-autoscaler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jthomperoo%2Fpredictive-horizontal-pod-autoscaler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jthomperoo","download_url":"https://codeload.github.com/jthomperoo/predictive-horizontal-pod-autoscaler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247526768,"owners_count":20953143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autoscaler","autoscaling","go","golang","horizontal-pod-autoscaler","kubernetes","operator","operator-framework","operator-sdk","predictions","predictive-analytics","python","replicas","statistical-models","statsmodels"],"created_at":"2024-11-23T23:51:48.327Z","updated_at":"2025-04-06T18:17:02.742Z","avatar_url":"https://github.com/jthomperoo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build](https://github.com/jthomperoo/predictive-horizontal-pod-autoscaler/workflows/main/badge.svg)](https://github.com/jthomperoo/predictive-horizontal-pod-autoscaler/actions)\n[![go.dev](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white\u0026style=flat)](https://pkg.go.dev/github.com/jthomperoo/predictive-horizontal-pod-autoscaler)\n[![Go Report Card](https://goreportcard.com/badge/github.com/jthomperoo/predictive-horizontal-pod-autoscaler)](https://goreportcard.com/report/github.com/jthomperoo/predictive-horizontal-pod-autoscaler)\n[![Documentation Status](https://readthedocs.org/projects/predictive-horizontal-pod-autoscaler/badge/?version=latest)](https://predictive-horizontal-pod-autoscaler.readthedocs.io/en/latest)\n[![License](https://img.shields.io/:license-apache-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)\n\n# Predictive Horizontal Pod Autoscaler\n\nPredictive Horizontal Pod Autoscalers (PHPAs) are Horizontal Pod Autoscalers (HPAs) with extra predictive capabilities,\nallowing you to autoscale using statistical models for ahead of time predictions.\n\n## Why would I use it?\n\nPHPAs can better scaling results by making proactive decisions to scale up ahead of demand, meaning that a\nresource does not have to wait for performance to degrade before autoscaling kicks in.\n\n## What systems would need it?\n\nAny systems that have regular/predictable demand peaks/troughs.\n\nSome use cases:\n\n* A service that sees demand peak between 3pm and 5pm every week day, this is a regular and predictable load which\ncould be pre-empted.\n* A service which sees a surge in demand at 12pm every day for 10 minutes, this is such a short time interval that\nby the time a regular HPA made the decision to scale up there could already be major performance/availablity issues.\n\nPHPAs are not a silver bullet, and require tuning using real data for there to be any benefits of using it. A poorly\ntuned PHPA could easily end up being worse than a normal HPA.\n\n## How does it work?\n\nThis project works by doing the same calculations as the Horizontal Pod Autoscaler does to determine how many replicas\na resource should have, then applies statistical models against the calculated replica count and the replica history.\n\n## Supported Kubernetes versions\n\nThe minimum Kubernetes version the autoscaler can run on is `v1.23` because it relies on the `autoscaling/v2` API which\nwas only available in `v1.23` and above.\n\nThe autoscaler is only tested against the latest Kubernetes version - if there are bugs that affect older Kubernetes\nversions we will try to fix them, but there is no guarantee of support.\n\n## Features\n\n* Functionally identical to Horizontal Pod Autoscaler for calculating replica counts without prediction.\n* Choice of statistical models to apply over Horizontal Pod Autoscaler replica counting logic.\n  * Holt-Winters Smoothing\n  * Linear Regression\n* Allows customisation of Kubernetes autoscaling options without master node access. Can therefore work on managed\nsolutions such as EKS or GCP.\n  * CPU Initialization Period.\n  * Downscale Stabilization.\n  * Sync Period.\n\n## What does a Predictive Horizontal Pod Autoscaler look like?\n\nPHPAs are designed to be as similar in configuration to Horizontal Pod Autoscalers as possible, with extra\nconfiguration options.\n\nPHPAs have their own custom resource:\n\n```yaml\napiVersion: jamiethompson.me/v1alpha1\nkind: PredictiveHorizontalPodAutoscaler\nmetadata:\n  name: simple-linear\nspec:\n  scaleTargetRef:\n    apiVersion: apps/v1\n    kind: Deployment\n    name: php-apache\n  minReplicas: 1\n  maxReplicas: 10\n  behavior:\n    scaleDown:\n      stabilizationWindowSeconds: 0\n  metrics:\n    - type: Resource\n      resource:\n        name: cpu\n        target:\n          averageUtilization: 50\n          type: Utilization\n  models:\n    - type: Linear\n      name: simple-linear\n      linear:\n        lookAhead: 10000\n        historySize: 6\n```\n\nThis PHPA acts like a Horizontal Pod Autoscaler and autoscales to try and keep the target resource's CPU utilization at\n50%, but with the extra predictive layer of a linear regression model applied to the results.\n\n## Installation\n\nThe operator for managing Predictive Horizontal Pod Autoscalers can be installed using Helm:\n\n```bash\nVERSION=v0.13.2\nHELM_CHART=predictive-horizontal-pod-autoscaler-operator\nhelm install ${HELM_CHART} https://github.com/jthomperoo/predictive-horizontal-pod-autoscaler/releases/download/${VERSION}/predictive-horizontal-pod-autoscaler-${VERSION}.tgz\n```\n\n## Quick start\n\nCheck out the [getting started\nguide](https://predictive-horizontal-pod-autoscaler.readthedocs.io/en/latest/user-guide/getting-started/) and the\n[examples](./examples/) for ways to use Predictive Horizontal Pod Autoscalers.\n\n## More information\n\nSee the [wiki for more information, such as guides and\nreferences](https://predictive-horizontal-pod-autoscaler.readthedocs.io/en/latest/).\n\nSee the [`examples/` directory](./examples) for working code samples.\n\n## Developing this project\n\nDeveloping this project requires these dependencies:\n\n* [Go](https://golang.org/doc/install) \u003e= `1.20`\n* [Python](https://www.python.org/downloads/) == `3.8.x`\n* [Helm](https://helm.sh/) == `3.9.x`\n\nAny Python dependencies must be installed by running:\n\n```bash\npip install -r requirements-dev.txt\n```\n\nThis extensively uses the the [jthomperoo/k8shorizmetrics](https://github.com/jthomperoo/k8shorizmetrics) library\nto gather metrics and to evaluate them as the Kubernetes Horizontal Pod Autoscaler does.\n\nIt is recommended to test locally using a local Kubernetes managment system, such as\n[k3d](https://github.com/rancher/k3d) (allows running a small Kubernetes cluster locally using Docker).\n\nYou can deploy a PHPA example (see the [`examples/` directory](./examples) for choices) to test your changes.\n\n### Commands\n\n* `make run` - runs the PHPA locally against the cluster configured in your kubeconfig file.\n* `make docker` - builds the PHPA image.\n* `make lint` - lints the code.\n* `make format` - beautifies the code, must be run to pass the CI.\n* `make test` - runs the unit tests.\n* `make doc` - hosts the documentation locally at \u003chttps://localhost:8000\u003e.\n* `make coverage` - opens up any generated coverage reports in the browser.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjthomperoo%2Fpredictive-horizontal-pod-autoscaler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjthomperoo%2Fpredictive-horizontal-pod-autoscaler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjthomperoo%2Fpredictive-horizontal-pod-autoscaler/lists"}