-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide scaler for GitHub Actions Runner #1732
Comments
Hi, I’ve been learning how to write a Keda scaler for a while. I wrote a basic scaler just to understand the scalers logic and wrote a blog about it, you can read my article here: https://melisatanrverdi.medium.com/how-do-i-cool-pods-with-keda-how-to-write-a-new-scaler-26b4671830bc |
Great article! :) @tomkerhove is the right person that could give you more info. |
The goal here is to autoscale self-hosted GitHub Actions runners to meet the current demand for it. This would please a lot of people as per actions/runner#395. In order to achieve that, we need to be able to get the related information:
|
I've done something similar here https://github.com/devjoes/github-runner-autoscaler It's not a custom scaler. It's just a custom metrics APIService that you can point the ExternalMetrics scaler at and autoscale a stateful set up and down. |
That looks interesting, thanks for sharing! Feel free to send a PR to https://github.com/kedacore/external-scalers if you want. However, this seems to rely on Prometheus which is a dependency we'd like to avoid. Can you share a bit on where you get the metrics from? |
Thanks! PR is here. It doesn't rely on Prometheus, it just exports its own metrics which can be consumed by Prometheus if the user wants. Essentially it just exposes a custom metric like this:
It then uses KEDA's metrics-api trigger to scale on The operator in that repo just wraps up the creation of StatefulSets and ScaledObjects. But there is no reason why you couldn't just deploy the API server and CRDs and point KEDA at it if you wanted to. |
Thanks for opening the PR! So the statefulset is then in charge of getting the metrics with GitHub to see how many pending actions there are, is that correct? |
So the stateful set just runs https://github.com/myoung34/docker-github-actions-runner
This queries a deployment called metrics, it is that deployment that checks the queued jobs |
A-ha, now I'm starting to get it - Thanks! Basically the runner itself has the metrics on the queued jobs, thanks! |
They have added webhook support but that's not really ideal: https://github.blog/changelog/2021-09-20-github-actions-ephemeral-self-hosted-runners-new-webhooks-for-auto-scaling/ |
@tomkerkhove there is a queue depth API @nilofer from GitHub is focusing on, hopefully available next month after their internal hackfest. I could make a PR to provide native scaler for GitHub Action |
That would be a major help - Thanks! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
Hey @tomkerkhove - Is there any progress on this one? Also interested, and happy to contribute if extra help is needed! Sounds like there are some limitations on the GitHub side to get this going though from what I'm reading. |
As far as I know, unless that changed, there is no simple way to get metrics today. GitHub advises to use actions-runner-controller/actions-runner-controller in their documentation. However, @nilofer might have an update on an API to poll as I'd love to have one next to our Azure Pipelines scaler. |
For anyone on this thread who is interested, I wrote a little post/tutorial on Autoscaling self hosted GitHub runner containers with Azure Container Apps (ACA) |
Nice workaround |
I've been in contact with GitHub related to github/roadmap#555 |
Needs some work, but I need a git scaler to sit alongside my azure pipelines scaler so writing one. It currently has the issue of if you have a lot of repos it will hit rate limits, so putting some code together to refine that bit. |
@tomkerkhove this is working in my dev clusters now. I haven't done a webhook version, this is a scale to zero, pull awaiting jobs version. Would you like this submitting? If so, I'll document it. |
do you have it working without webhooks? I mean, are you recovering the info using the rest API? |
Yeah, all using the rest api. Will document it and submit a PR. Cheers, Andy |
Wonderful, thank you! |
Implemented |
FYI The new implementation of action-runner controller from github is promising. |
Proposal
Provide scaler for GitHub Actions Runner
https://github.com/actions/runner
Scaler Source
GitHub Actions Runner queue
Scaling Mechanics
Automatically scale out based on the pending actions to run.
Authentication Source
TBD
The text was updated successfully, but these errors were encountered: