Sub topic 11
Customizing the runner image and pod template
This chapter shows how to replace the default runner image and edit the pod that ARC creates for each job. It assumes you have already installed the controller and a working runner scale set with Helm. It also assumes you can read a Kubernetes pod spec and build and push a container image.
Why the defaults are not enough
The default scale set runs the image ghcr.io/actions/actions-runner. It contains the runner agent and a small set of tools, and it is deliberately minimal. Real pipelines usually need more:
- Build tools such as
jq,unzip, a specific compiler, or a cloud CLI. - Predictable resource usage, so one heavy job does not starve its neighbors.
- Private registry access, a dedicated service account, or extra environment variables.
You have two levers, and they work together:
- The runner image decides what software is inside the container.
- The pod template decides how Kubernetes runs that container: resources, volumes, environment, scheduling.
Both are applied to every ephemeral runner pod the scale set creates. Because each pod runs one job and is deleted, a change reaches jobs through new pods, not through edits to running ones.
Building a custom runner image
Start from the official runner image and add only what your jobs need. Pin a version tag so builds are repeatable.
FROM ghcr.io/actions/actions-runner:2.321.0
USER root
RUN apt-get update \
&& apt-get install -y --no-install-recommends jq unzip \
&& rm -rf /var/lib/apt/lists/*
USER runnerThe base image runs as the non-root user runner. Package installs need root, so the file switches to root for the install and back to runner at the end. Leaving the image on root would run every job as root inside the container.
Build and push it to a registry your cluster can reach:
docker build -t registry.example.com/ci/runner:2.321.0-1 .
docker push registry.example.com/ci/runner:2.321.0-1Use a unique tag for every build, such as the runner version plus a build number. Avoid latest for your own image. Nodes cache images, and a mutable tag makes it hard to tell which version a given job ran on.
The runner agent is more than a tool in the image. GitHub stops accepting runner versions that are too old. If you pin a version, plan to rebuild on a schedule so the pin does not go stale.
Wiring the image into the scale set
The chart exposes the pod spec under template.spec. You override only the parts you want to change. This values file uses your custom image and sets resources, and it reuses the organization-level settings from the earlier example:
githubConfigUrl: "https://github.com/<your-org>"
githubConfigSecret: pre-defined-secret
minRunners: 1
maxRunners: 20
template:
spec:
imagePullSecrets:
- name: registry-credentials
containers:
- name: runner
image: registry.example.com/ci/runner:2.321.0-1
command: ["/home/runner/run.sh"]
resources:
requests:
cpu: "1"
memory: 2Gi
limits:
memory: 4GiApply it with a Helm upgrade of the same release name:
helm upgrade --install arc-runner-set \
--namespace arc-runners \
-f values.yaml \
oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-setThe imagePullSecrets entry refers to a Kubernetes secret of type kubernetes.io/dockerconfigjson in the arc-runners namespace. Pods can only use pull secrets from their own namespace, so create it there, not in arc-systems.
Rules the template must follow
- The runner container must be named
runner. The chart looks for that name to merge its own settings. A differently named container becomes an extra container in the pod, and the real runner is still the default one. - Keep
command: ["/home/runner/run.sh"]. That script starts the runner agent. ARC passes registration details to it through environment variables, so a replaced command that does not call it leaves a pod that never picks up a job. - Do not set the runner's registration variables yourself. ARC injects a just-in-time configuration for each pod. Your values would conflict with it.
- Your template merges with the chart's own additions. A container mode such as
dindorkubernetesadds containers, volumes, and environment on top of what you write. Check the final result before you rely on it.
To preview the pod the chart will produce, render it locally without installing anything:
helm template arc-runner-set \
--namespace arc-runners \
-f values.yaml \
oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-setLook in the output for the AutoscalingRunnerSet resource and read its template section.
Common pod template additions
Beyond image and resources, a few fields come up often.
Environment variables and secrets
Add plain values to the runner container with env. Pull sensitive values from a secret reference instead of writing them in the values file:
template:
spec:
containers:
- name: runner
image: registry.example.com/ci/runner:2.321.0-1
command: ["/home/runner/run.sh"]
env:
- name: HTTPS_PROXY
value: "http://proxy.internal:3128"
- name: ARTIFACT_TOKEN
valueFrom:
secretKeyRef:
name: artifact-credentials
key: tokenRemember that every job on this scale set can read these variables. Anything you place in the pod is visible to the workflow code that runs there, so do not mount credentials that only some repositories should use.
Service account and volumes
Set serviceAccountName when jobs need cloud permissions through workload identity. Use volumes and volumeMounts for a shared cache or a custom CA bundle. Because the pod is deleted after one job, an emptyDir volume is cleaned up automatically, and a persistent volume is only worth it when you deliberately want state to outlive a job.
Scheduling
nodeSelector, tolerations, and affinity live in the same template.spec. The next chapter covers them in detail, so this chapter only notes that they use the same mechanism.
Verifying the result
Confirm the new image works by running a job that checks for the tool you installed. This workflow targets the scale set by its installation name:
name: Runner image check
on: workflow_dispatch
jobs:
check:
runs-on: arc-runner-set
steps:
- run: jq --version
- run: cat /etc/os-release | head -n 2While the job runs, inspect the pod to see which image it actually used:
kubectl get pods -n arc-runners
kubectl get pod <runner-pod-name> -n arc-runners \
-o jsonpath='{.spec.containers[?(@.name=="runner")].image}'Pods that existed before the upgrade keep their old image until they finish. With minRunners above zero, idle runners from before the upgrade may serve a job or two. This is normal. They disappear as jobs complete and new pods replace them.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Pod stuck in `ImagePullBackOff` | Missing or wrong pull secret, or wrong tag | Create the secret in `arc-runners` and check the image name |
| Pod starts, then exits immediately | `command` replaced with something other than `run.sh` | Restore `/home/runner/run.sh` |
| Two containers in the runner pod | The container is not named `runner` | Rename it to `runner` |
| `apt-get` fails with permission denied inside a job | Packages installed at job time as the non-root user | Install packages in the image instead |
| Pod stays `Pending` | Requests exceed what any node can offer | Lower requests or add capacity |
| Job killed with exit code 137 | Container exceeded its memory limit | Raise `limits.memory` |
| Runner is rejected as outdated | Pinned runner version is too old | Rebuild from a newer base tag |
Exercise
A teammate upgrades the scale set to a new image tag. The next job still reports the old version of a tool, and minRunners is 3. What is the most likely explanation, and how can you confirm it?
Show answer
The job ran on one of the idle runner pods that existed before the upgrade, because running pods keep the image they were created with. Confirm by listing the pods in arc-runners and reading the runner container's image with kubectl get pod <name> -o jsonpath (or kubectl describe pod). Pods created after the upgrade show the new tag, and the old ones go away as they finish their jobs.
Exercise
You add a second container to template.spec.containers and name it build-tools instead of runner, then set the image on that container only. Jobs still run with the default tools. Why?
Show answer
The chart treats the container named runner as the runner container. Your build-tools container is added as an extra container, and the actual runner still uses the default image. To change the runner's image, set image on the container named runner.