{"id":16880002,"url":"https://github.com/aledbf/horus-proxy","last_synced_at":"2025-03-20T02:32:23.326Z","repository":{"id":149110080,"uuid":"183150710","full_name":"aledbf/horus-proxy","owner":"aledbf","description":null,"archived":false,"fork":false,"pushed_at":"2019-07-11T16:35:52.000Z","size":11300,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-14T16:09:04.019Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/aledbf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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-04-24T04:54:13.000Z","updated_at":"2024-06-19T12:18:26.046Z","dependencies_parsed_at":"2023-05-01T14:02:23.432Z","dependency_job_id":null,"html_url":"https://github.com/aledbf/horus-proxy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aledbf%2Fhorus-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aledbf%2Fhorus-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aledbf%2Fhorus-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aledbf%2Fhorus-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aledbf","download_url":"https://codeload.github.com/aledbf/horus-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244538575,"owners_count":20468740,"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":[],"created_at":"2024-10-13T15:56:54.995Z","updated_at":"2025-03-20T02:32:23.306Z","avatar_url":"https://github.com/aledbf.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Horus Proxy - A general purpose, Scale to Zero component for Kubernetes\n\nHorus enables greater resource efficiency within a Kubernetes cluster by\nallowing idling workloads to automatically scale-to-zero and allowing\nscaled-to-zero workloads to be automatically re-activated on-demand\nby inbound requests.\n\nThis project started after using [Osiris](https://github.com/deislabs/osiris) ([Horus is Osiris son](https://en.wikipedia.org/wiki/Horus))\n\n## How it works\n\nIn Kubernetes, there is no direct relationship between deployments and services.\nDeployments manage pods and services may select pods managed by one or more deployments.\nFor this reason, the next example allows us to define this relationship and some context \nabout the idle time after we want to scale to zero and the minimum number of replicas \nthat should be started when we scale from zero.\n\nUsing a [Kubernetes Custom Resources or CRD](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/), we define the relationship between the deployment and the service to use plus other details about the behavior we expect.\n\n```yaml\napiVersion: autoscaler.rocket-science.io/v1beta1\nkind: Traffic\nmetadata:\n  name: proxy-echoheaders\nspec:\n  deployment: echoheaders\n  service: echoheaders-svc\n  idleAfter: 30s\n  minReplicas: 2\n```\n\nThis example will use a deployment called `echoheaders` in the default namespace\nwith the service `echoheaders-svc`. Once horus detects the `Traffic` definition\nit creates a new deployment `\u003cdeployment\u003e-\u003csvc\u003e-horus-proxy` using the same\n`matchLabels` defined in the deployment, adding a new selector `handled-by: horus-proxy`.\nThe horus controller also changes the service adding a new label\n`handled-by: horus-proxy`.\n\nAdding a new label we callows us to route traffic using the horus-proxy pod instead of the\nones defined in the original deployment. **This is the main difference with Osiris**\n\nHorus Proxy consists in two components, a Go program (controller) and NGINX. The controller\nrole is the generation of the NGINX configuration file with information of the pods running\nin the cluster and also the extraction of prometheus metrics from NGINX to know if there are\none or more requests being hold because there are no running pods and to know the last time\nthe proxy processed a request.\nOnce the proxy receives a request, NGINX checks if there is a running pod for the deployment.\nIn case there is no running pod, it holds the traffic until there is an available one. Every\nfive seconds the controller checks the metrics and if the metric `http_requests_waiting_endpoint`\nis \u003e 0 it means NGINX is waiting for a pod. If this happens the controller scales the deployment\nto one replica. Once the pod is running the controller updates the NGINX configuration \n(using Lua) without restarting NGINX.\n\n### Scaling to zero and the HPA\n\nHorus is designed to work alongside the Horizontal Pod Autoscaler and is not meant to replace \nit -- it will scale your pods from n to 0 and from 0 to n, where n is a configurable minimum \nnumber of replicas (one, by default).\nAll other scaling decisions may be delegated to an HPA, if desired.\n\nAt some point, there will be no pending requests. When this happends and after the `idleAfter` \ntime definition the controller will scale the deployment to zero.\n\n## Setup\n\nPrerequisites:\n\n* A running Kubernetes cluster\n\n### Install horus\n\nTODO\n\n### Example\n\nTODO\n\n# horus-proxy\n\n- Deploy echoheaders server running `kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/docs/examples/http-svc.yaml`\n- Deploy proxy `kubectl apply -f https://raw.githubusercontent.com/aledbf/horus-proxy/master/deployment.yaml`\n- Watch proxy log\n- Scale deployment `http-svc` up/down\n- Check last request metric /last-request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faledbf%2Fhorus-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faledbf%2Fhorus-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faledbf%2Fhorus-proxy/lists"}