Sub topic 1
Why run your own GitHub Actions runners
Prerequisites
This chapter assumes you already know the following:
- Basic GitHub Actions workflows: jobs, steps, and the
runs-onkey. - Kubernetes basics: pods, namespaces, and secrets.
- How to use
kubectlagainst a cluster. - Basic Helm usage and container image basics.
You won't install anything here. This chapter explains when self-hosting makes sense, so the later chapters on Actions Runner Controller (ARC) have a purpose.
Hosted and self-hosted runners
A runner is the machine that executes the steps of a job. GitHub offers two kinds:
- GitHub-hosted runners are virtual machines that GitHub creates, patches, and destroys for you. You select one with a label such as
ubuntu-latest. - Self-hosted runners are machines you operate. You install the runner application on them and register them with GitHub. Jobs select them by label, such as
runs-on: self-hosted.
The workflow file looks almost the same in both cases. Only the runs-on value changes.
name: Runner comparison
on: workflow_dispatch
jobs:
hosted:
runs-on: ubuntu-latest
steps:
- run: echo "GitHub runs this machine"
self:
runs-on: self-hosted
steps:
- run: echo "You run this machine"Reasons to run your own
Teams usually move to self-hosted runners for one of these reasons.
| Reason | What it means in practice |
|---|---|
| Network access | Jobs can reach private databases, registries, or internal APIs that are not exposed to the internet. |
| Hardware | You can use more CPU or memory, GPUs, or ARM machines that hosted runners do not offer. |
| Cost at scale | Heavy, steady build load can be cheaper on infrastructure you already pay for. |
| Compliance | Code and secrets stay inside an environment you control and audit. |
| Custom tooling | You can preinstall large toolchains and warm caches in the image. |
What you take on
Self-hosting moves work from GitHub to you.
- Patching and maintenance. You update the operating system and the runner application. Old runner versions eventually stop receiving jobs.
- Capacity. If you have too few runners, jobs wait in the queue. If you have too many, you pay for idle machines.
- Security. A runner executes whatever code a workflow contains. A long-lived runner can keep files, credentials, and processes from one job and expose them to the next.
The static runner problem
The simplest self-hosted setup is a fixed set of long-lived machines. It has three common problems:
- Idle cost. Machines run at night and on weekends with nothing to do.
- Queueing. A burst of pull requests exceeds the fixed capacity, and jobs wait.
- State leakage. Jobs share a filesystem and process space over time. One job's leftover files can break the next job. A malicious job can plant something that affects later jobs.
You can avoid all three problems with runners that are created on demand, run exactly one job, and are then deleted. The next chapter covers these ephemeral runners. After that, ARC shows how to run them as pods on Kubernetes and scale them with the job queue.
Exercise
A team's integration tests need a database that is reachable only from inside their private network. Their build load is small and irregular. Name the main reason to self-host here, and one cost the team accepts.
Show answer
The main reason is network access to the private database. The team accepts responsibility for patching, capacity, and security of the runners. With irregular load, a fixed set of machines would also sit idle part of the time, which points toward on-demand runners.