{"id":13839358,"url":"https://github.com/jthomperoo/horizontal-pod-autoscaler","last_synced_at":"2025-07-11T03:31:59.695Z","repository":{"id":40330563,"uuid":"222764979","full_name":"jthomperoo/horizontal-pod-autoscaler","owner":"jthomperoo","description":"Horizontal Pod Autoscaler, modified to work as a Custom Pod Autoscaler","archived":true,"fork":false,"pushed_at":"2022-12-18T14:23:56.000Z","size":256,"stargazers_count":18,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-21T04:31:00.163Z","etag":null,"topics":["autoscaler","custom-pod-autoscaler","example","hacktoberfest","kubernetes-hpa"],"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":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-19T18:42:50.000Z","updated_at":"2024-04-13T10:07:41.000Z","dependencies_parsed_at":"2023-01-29T19:15:59.424Z","dependency_job_id":null,"html_url":"https://github.com/jthomperoo/horizontal-pod-autoscaler","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/jthomperoo/horizontal-pod-autoscaler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jthomperoo%2Fhorizontal-pod-autoscaler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jthomperoo%2Fhorizontal-pod-autoscaler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jthomperoo%2Fhorizontal-pod-autoscaler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jthomperoo%2Fhorizontal-pod-autoscaler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jthomperoo","download_url":"https://codeload.github.com/jthomperoo/horizontal-pod-autoscaler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jthomperoo%2Fhorizontal-pod-autoscaler/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264721330,"owners_count":23653920,"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","custom-pod-autoscaler","example","hacktoberfest","kubernetes-hpa"],"created_at":"2024-08-04T17:00:20.270Z","updated_at":"2025-07-11T03:31:59.396Z","avatar_url":"https://github.com/jthomperoo.png","language":"Go","funding_links":[],"categories":["Autoscaler"],"sub_categories":[],"readme":"\u003e # ARCHIVED AND READ ONLY - This project has been archived and marked as read only, it is no longer maintained.\n\u003e # You can still access the source code and run the examples, but no further code fixes will be made to this project.\n\u003e # Feel free to fork this if you want to continue working on it.\n\n[![Build](https://github.com/jthomperoo/horizontal-pod-autoscaler/workflows/main/badge.svg)](https://github.com/jthomperoo/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/horizontal-pod-autoscaler)\n[![Go Report Card](https://goreportcard.com/badge/github.com/jthomperoo/horizontal-pod-autoscaler)](https://goreportcard.com/report/github.com/jthomperoo/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# Custom Pod Autoscaler - Horizontal Pod Autoscaler (CPA-HPA)\n\nThis is the Horizontal Pod Autoscaler (HPA), modified to work as a [Custom Pod Autoscaler\n(CPA)](https://github.com/jthomperoo/custom-pod-autoscaler). This project is designed to be a starting point to allow\ndevelopers to quickly take a working Horizontal Pod Autoscaler and modify it as they need.\n\n## What is a Custom Pod Autoscaler?\n\nA Custom Pod Autoscaler is a way to write custom logic into Kubernetes scalers.\nFor more detailed overview, see the [Custom Pod Autoscaler\nFramework](https://custom-pod-autoscaler.readthedocs.io/en/latest/).\n\n## How do I use this project?\n\nIf you want to deploy this CPA-HPA onto your cluster, you first need to install the [Custom Pod Autoscaler\nOperator](https://github.com/jthomperoo/custom-pod-autoscaler-operator), follow the [installation guide for\ninstructions for installing the\noperator](https://github.com/jthomperoo/custom-pod-autoscaler-operator/blob/master/INSTALL.md).\n\n## Overview of codebase\n\nThis project should be functionally similar/identical to the Kubernetes Horizontal Pod Autoscaler, with differences\nbeing that this is run as a CPA rather than a Kubernetes controller. The code is largely copied from the Kubernetes\nHPA and modified to work with the Custom Pod Autoscaler. Some restructuring of the architecture was required to fit\nwith how a CPA operates, with the HPA logic now split into two distinct parts; metric gathering and evaluation.\n\n### Metric Gathering\n\nThe metric gathering stage takes in a resource to gather metrics for, and metric spec definitions for which metrics\nto gather. Using this information the metrics are gathered and calculated, from metrics APIs. These metrics are then\nserialised into JSON and output back to the CPA through stdout.\n\n### Evaluation\n\nThe evaluation stage takes in the metrics gathered by the metric gathering stage and makes a decision - how many\nreplicas should the resource have. Once this decision has been made using data available the decision is serialised\ninto JSON and output back to the CPA through stdout to do the actual scaling.\n\n### Configuration\n\nThere is some overlap in functionality between the the CPA and HPA, in this project precedence has been given to the\nCPA functionality. For example, Kubernetes HPAs have the ability to set minimum and maximum replica counts, this\nproject removes those and instead relies on the CPA minimum and maximum replica counts. A Kubernetes HPA also contains\na ScaleTargetRef for deciding which resource to target when scaling; for this project only the ScaleTargetRef of the\nCPA is used.\n\nDeciding which metrics to use is done by using `MetricSpecs`, which are a key part of HPAs, and look like this:\n\n```yaml\n- type: Resource\n  resource:\n    name: cpu\n    target:\n        type: Utilization\n        averageUtilization: 50\n```\n\nTo send these specs to the CPA-HPA, add a config option called `metrics` to the CPA, with a multiline string\ncontaining the metric list. For example:\n\n```yaml\nconfig:\n  - name: metrics\n    value: |\n      - type: Resource\n        resource:\n          name: cpu\n          target:\n            type: Utilization\n            averageUtilization: 50\n```\n\n## Example\n\nThere is an example of how to use the Custom Pod Autoscaler - Horizontal Pod Autoscaler in [`/example`](./example).\nThe example has a simple deployment, taken from the [Kubernetes Horizontal Pod Autoscaler\nwalkthrough](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/). The example also\ncontains the YAML definition of the CPA-HPA.\n\n## More information\n\nSee the [wiki for more information, such as guides and\nreferences](https://horizontal-pod-autoscaler.readthedocs.io/en/latest/).\n\n## Developing this project\n### Environment\nDeveloping this project requires these dependencies:\n\n* [Go](https://golang.org/doc/install) \u003e= 1.17\n* [staticcheck](https://staticcheck.io/docs/getting-started/) == `v0.3.0 (2022.1)`\n* [Docker](https://docs.docker.com/install/)\n\nTo view the docs, you need Python 3 installed:\n\n* [Python](https://www.python.org/downloads/) \u003e= `3.8`\n\nTo view docs locally you need some Python dependencies, run:\n\n```bash\npip install -r docs/requirements.txt\n```\n\n### Commands\n\n* `make` - builds the CPA-HPA binary.\n* `make docker` - builds the CPA-HPA image.\n* `make lint` - lints the code.\n* `make format` - formats the code.\n* `make test` - runs the project tests.\n* `make doc` - hosts the documentation locally, at `127.0.0.1:8000`.\n* `make coverage` - shows the test coverage report.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjthomperoo%2Fhorizontal-pod-autoscaler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjthomperoo%2Fhorizontal-pod-autoscaler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjthomperoo%2Fhorizontal-pod-autoscaler/lists"}