Sub topic 11
Customizing the runner image and pod template
This chapter assumes you have installed the controller and a runner scale set with Helm, and that you know the basics of pod specs and container images. You will change what runs inside each ephemeral runner pod.
Where customization happens
The scale set chart builds each runner pod from a template. The template.spec key in your values file is merged into that pod spec. You can set the image, command, resources, environment variables, volumes, and more. Anything you leave out falls back to the chart's defaults, including the mode-specific settings from containerMode.
Overriding the runner container
The container that executes jobs must be named runner. If you use another name, the chart adds its own runner container and your settings are ignored. The next values file registers the scale set at organization level, keeps one warm runner, and sets the image, start command, and resources.
githubConfigUrl: "https://github.com/<your-org>"
githubConfigSecret: pre-defined-secret
minRunners: 1
maxRunners: 20
template:
spec:
containers:
- name: runner
image: ghcr.io/actions/actions-runner:latest
command: ["/home/runner/run.sh"]
resources:
requests:
cpu: "1"
memory: 2Gi
limits:
memory: 4GiThe command must start the runner process. In the official image that is /home/runner/run.sh. Pin the image to a version tag instead of latest in production. GitHub requires runners to stay reasonably current, and a pinned tag lets you control when the change happens.
Building a custom image
Start from the official image and add the tools your jobs need. This avoids reinstalling them in every job, which matters because each job gets a fresh pod.
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 runnerSwitch back to the runner user at the end. The runner refuses to run as root, and jobs should not have root anyway. Replace the version tag with a current release, push the image to a registry the cluster can pull from, and reference it in template.spec.containers[0].image. If the registry is private, add imagePullSecrets under template.spec.
Adding volumes and environment variables
Other pod-level fields go in the same template. This example adds an environment variable and a shared scratch volume.
template:
spec:
containers:
- name: runner
image: ghcr.io/actions/actions-runner:2.321.0
command: ["/home/runner/run.sh"]
env:
- name: HTTPS_PROXY
value: "http://proxy.internal:3128"
volumeMounts:
- name: scratch
mountPath: /scratch
volumes:
- name: scratch
emptyDir: {}An emptyDir volume is deleted with the pod, which fits the one-job-one-environment model.
Common errors
| Symptom | Likely cause |
|---|---|
| Pod starts but never takes a job | `command` does not start `run.sh`, or the container is not named `runner` |
| `ImagePullBackOff` | Wrong tag, or a private registry without `imagePullSecrets` |
| Your settings have no effect | Values placed outside `template.spec`, or a typo in the key |
| Jobs fail with permission errors | The Dockerfile left the user as `root`, or files are owned by the wrong user |
| Pod is `OOMKilled` | Memory limit is too low for the job |
After changing values, apply them with helm upgrade. Running jobs keep their old pods. New pods use the updated template.
Exercise
A teammate sets a custom image under a container named custom-runner in template.spec.containers. Jobs still run with the default image. Why, and how do you fix it?
Show answer
The chart only customizes the container named runner. A container with another name is treated as an extra container, so the chart still adds its own default runner container. Rename the container to runner, keep command set to /home/runner/run.sh, and run helm upgrade.