Autoscaling self-hosted Github Actions Runners in K8s with AWS Karpenter

Wang Poh Peng
2 min readSep 8, 2023

--

A brief explanation of how AWS Autoscaling of EC2 EKS nodes usually work in AWS EKS Cluster:

  • cluster-autoscaler installed
  • permissions given to the cluster-autoscaler to modify launch templates

Today we will be understanding how we can use the brand new AWS Karpenter instead.

What is AWS Karpenter?

Karpenter is an open-source, flexible, high-performance Kubernetes cluster autoscaler built with AWS, however it works with any other cloud providers as well.

The difference here is:

  • cluster-autoscaler is cloud agnostic, any Cloud Providers can work with it to autoscale accordingly.
  • cluster-autoscaler uses launch template APIs to manage the autoscaling groups in AWS to scale then nodes.
  • Karpenter uses AWS APIs directly to create and delete EC2 instances, assigning them as AWS EKS Nodes as required. Update: Karpenter now supports other cloud providers as well

Understanding the Github Actions Self-hosted runners arch:

Actions Runner Controller

Recently it was announced that this project is adopted by GitHub officially and they will be making a public beta on the next version’s implementation soon.

A Helm chart is also available. Note the version differences between the Application version and the Chart version, they correspond to one another but the Application version can be configured via the chart

Currently I am working at SPH Media Trust Singapore and we have open sourced our implementation via a Terraform module.

This module deploys the helm chart using Terraform’s helm_release resource and manage the CRD resources in kubernetes_manifest resources

NodeTemplate

Provisioner

Actions Controller Helm Chart

  • CRD resource creation
  • Controller deployment
  • Webhook for autoscaling Github Actions Runners

Horizontal Runner Autoscaler

RunnerDeployment

However, there is a new version that is currently being developed as the project was officially adopted by GitHub.

Stay tuned as I update this space to use the completely rewrote version of actions controller.

Sign up to discover human stories that deepen your understanding of the world.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Wang Poh Peng
Wang Poh Peng

Written by Wang Poh Peng

Technology Enthusiast & Culture Explorer

No responses yet

Write a response