Platform · Enterprise

Self-Hosted GitHub Actions Runners on Kubernetes with Actions Runner Controller

Deploy Actions Runner Controller with Helm so CI jobs scale on cluster capacity, run ephemerally, and reach private networks that hosted runners cannot.

  • Actions Runner Controller
  • Helm
  • Kubernetes
  • GitHub Actions
  • Autoscaling
  • Docker-in-Docker
  • Workload identity
  • Prometheus

// Why this matters

Self-hosted GitHub Actions runners on Kubernetes solve two problems at once: jobs that need to reach private infrastructure, and CI cost and capacity that does not scale well on a fixed fleet of virtual machines. Hosted runners cannot see a private cluster API, an internal registry or a database behind a firewall, and teams end up opening networks or smuggling credentials to make deploy jobs work.

If you already operate Kubernetes, the cluster is the natural home for runners. It has the networking, the identity integration and a node autoscaler. The platform in One Reusable Plan/Apply Workflow for Cost-Optimised Autoscaling and the onboarding pipeline in From Form to Running Cluster: Self-Service Team Onboarding both rely on workflows that need such private reach.

// The problem

Long-lived runner VMs accumulate state. A previous job leaves files, a cached credential or a half-installed tool, and builds start to differ depending on which machine picks them up. They also idle at full price overnight and run out of capacity during a busy merge window.

The older approaches to Kubernetes runners have their own sharp edges: pods that register once and live forever, token-based registration with personal access tokens that expire or are over-scoped, and docker socket mounting that gives every job root on the node. You want clean per-job isolation, cheap idle and credentials that are scoped to the minimum.

// The solution

ARC's current architecture has a controller and runner scale sets. The controller manages the lifecycle. A listener pod for each scale set holds a long-lived connection to GitHub and receives the number of queued jobs; the controller then creates exactly that many ephemeral runner pods, up to the maximum. When a pod finishes its single job it deregisters and is deleted.

Authentication uses a GitHub App installed on the organisation with just the permissions needed for self-hosted runners. The App id, installation id and private key go into a Kubernetes secret that the scale set references. This avoids personal tokens tied to a person who might leave.

For container builds I run Docker in Docker mode, a privileged sidecar inside the runner pod, scoped to that pod. It avoids mounting the host docker socket but still requires privileged containers, so I put such runners on a dedicated node pool with taints. Where possible, rootless builders such as Kaniko or BuildKit avoid privilege entirely.

I rejected a static pool of runners on virtual machines (idle cost and state drift) and rejected a webhook-driven custom autoscaler (more moving parts than the supported listener). Pools are split by trust: pull requests from forks never share runners with deploy workflows that hold cloud identity.

How it flows flow1. Create GitHub App → 2. Install controller → 3. Create secret → 4. Install scale set → 5. Workflow queued → 6. Gate: listener → 7. Scale up → 8. Run job → 9. Scale down01Create GitHub App02Install controller03Create secret04Install scale set05Workflow queued06 · GATEGate: listener07Scale up08Run job09Scale down
How it flows. End-to-end flow. Dashed pink nodes are gates: points where a human or a check must pass before the next stage runs.
  1. Create GitHub Apporganisation-scoped, runner permissions only
  2. Install controllerHelm chart, controller namespace
  3. Create secretApp id and private key stored as a Kubernetes secret
  4. Install scale setmin 0, max N, runner image, labels
  5. Workflow queueda job targets the scale-set name
  6. Gate: listener gatecontroller sees the pending job via the long poll
  7. Scale upephemeral runner pods created on demand
  8. Run jobpod registers, executes one job and exits
  9. Scale downpods removed, nodes reclaimed by the autoscaler
WorkflowGitHubListenerControllerRunner podjob queued with runs-on labellong poll reports 1 pending jobdesired runners = 1create ephemeral podregister and pick up jobreport result, deregister, exit
Life of one job on an ARC scale set. The listener learns of queued jobs and the controller creates one pod per job.
GitHubGitHub Appworkflow queuerunner groupsControl planecontroller podlistener per setCRDsRunnersephemeral podsdind sidecartool imageNodesrunner node poolautoscalerprivate network
Where the pieces live. Controller and listeners are small and long-lived; runners are short-lived.

// Before you start

  • A Kubernetes cluster (1.27 or newer) with a node autoscaler and outbound access to GitHub
  • Helm 3.12 or newer and kubectl
  • Organisation owner rights to create and install a GitHub App
  • A runner image (the upstream runner image works, or your own with tools baked in)
  • A decision on isolation: which repositories may use which pool

// Step-by-step implementation

  1. 01 Step 1. Create the GitHub App and the Kubernetes secret

    Create an organisation-owned GitHub App with the organisation self-hosted runners permission set to read and write and repository metadata read. Install it on the organisation, note the App id and installation id, and generate a private key.

    Create the namespace and secret. The key stays on your machine only long enough to create the secret; do not commit it.

  2. 02 Step 2. Install the controller

    The controller is installed once per cluster. It watches the runner CRDs and creates pods. Pin the chart version so upgrades are deliberate; the controller and scale-set charts should share a version.

  3. 03 Step 3. Define the runner scale set values

    The values file is where policy lives: the organisation URL, the secret, min and max runners and the pod template. A minimum of zero gives free idle; a minimum of one or two removes cold-start latency if you can afford it.

    Use a node selector and toleration so runner pods land on a dedicated pool, and set resource requests so the scheduler packs them sensibly.

  4. 04 Step 4. Install the scale set

    Each scale set is its own Helm release, which means you can run several with different sizes, images or runner groups. The release name becomes the label workflows use.

  5. 05 Step 5. Point a workflow at the scale set

    Use the scale set name as runs-on. Keep an echo step that proves the job is inside the private network, for instance by resolving an internal name or calling an internal endpoint.

  6. 06 Step 6. Split pools by trust level

    Create a second scale set for deploy workflows with its own node pool, a stricter runner group limited to protected repositories, and cloud identity attached through workload identity. Pull request builds from forks should never run there. This mirrors the least-privilege split described in Typos Cannot Reach Production: Declarative SaaS Access with Plan-Time Guards.

  7. 07 Step 7. Observe and cap the system

    Scale-set metrics (queued jobs, running runners) can be scraped. Add an alert for jobs queued longer than a few minutes, which usually means max runners is too low or nodes cannot scale. Apply a ResourceQuota on the runner namespace as a last line of defence against runaway scaling.

// How to verify it works

  • kubectl -n arc-systems get pods shows the controller and one listener pod for the scale set, both Running.
  • With no jobs queued, kubectl -n arc-runners get pods shows zero runner pods when minRunners is 0.
  • Trigger the workflow; a runner pod appears within seconds and the job starts on it.
  • After the job completes, the pod is gone and the runner no longer appears in the organisation runner list.
  • The private-reach step resolves and reaches the internal endpoint, which a hosted runner could not.

// Design decisions and trade-offs

  • Ephemeral runner pods: one job per pod, so no state leaks between builds and capacity returns when the job ends.
  • Runner scale sets with a minimum of zero and a sensible maximum, so idle cost is nothing and bursts are capped.
  • Runners live in the private network, which is the main reason to self-host: they can reach internal registries, clusters and databases.
  • Authentication through a GitHub App rather than a personal token, scoped to the organisation.
  • Separate runner pools per trust level, so untrusted workflows never share nodes with deployment credentials.

// Pitfalls and lessons learned

  • Mixing chart versions between the controller and scale set. Keep them identical and upgrade the controller first.
  • Privileged Docker in Docker on shared nodes. Put it on a tainted pool and prefer rootless builders where possible.
  • A personal access token for registration. It expires or leaves with its owner; use a GitHub App.
  • Forgetting runner groups. Without restricting which repositories can use a scale set, any repo in the organisation can run on your private network.
  • Setting maxRunners above what nodes or quotas allow, which leaves jobs queued with pods pending.
  • Caching on the pod filesystem. Ephemeral pods start clean every time; use the actions cache or a shared registry cache.

// Frequently asked questions

How do I set up self-hosted GitHub Actions runners on Kubernetes?

Install Actions Runner Controller with Helm, authenticate with a GitHub App, then install a runner scale set and use its name in runs-on.

Are ARC runners ephemeral?

Yes. Each pod runs one job, deregisters and is deleted, which gives clean state per build and returns capacity immediately.

Can ARC scale to zero?

Yes. Set minRunners to 0 and the listener creates pods only when jobs are queued; the node autoscaler then removes idle nodes.

Do I need privileged containers to build images on ARC?

Docker in Docker mode needs privilege. Kubernetes mode or a rootless builder such as BuildKit or Kaniko avoids it.

Why are my jobs stuck waiting for a runner?

Typically the scale-set name in runs-on does not match, max runners is reached, the listener is down or pods are pending for lack of node capacity.

// The outcome

CI jobs now scale on cluster capacity, run in clean ephemeral pods inside the private network and reach internal resources, without maintaining a fleet of long-lived runner VMs.

// Where to take it next

// Keep reading