Sub topic 12
Resources, node selection, and tolerations
This chapter covers how to size runner pods and control which nodes they land on. It assumes you can read a Helm values file and know what a pod spec, a node label, and a taint are. It also assumes you have a working scale set from the earlier chapters.
Why scheduling matters for runners
Runner pods are ordinary Kubernetes pods. The scheduler places each one on a node with enough free CPU and memory. Builds are bursty, so a few badly sized pods can starve other workloads or get killed mid-job. Sizing and placement settings live in the template.spec section of the scale set values file. That section is a standard pod spec.
Requests and limits
A request is the amount of a resource the scheduler reserves for the container. A limit is the ceiling the container may use.
- CPU is compressible. A container that exceeds its CPU limit is throttled, so the job runs slower.
- Memory is not compressible. A container that exceeds its memory limit is killed with an out-of-memory (OOM) error, and the job fails.
A common pattern for builds is to set a CPU request without a CPU limit, and to set a memory limit above the memory request. This lets builds use spare CPU and gives them headroom for memory spikes.
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: 4GiIf you use dind mode, the dind sidecar container also needs resources, because the Docker builds run there. Setting requests only on the runner container leaves the sidecar unbounded.
Choosing nodes
Two mechanisms work together. A node selector attracts pods to nodes with a given label. A toleration allows pods onto nodes that carry a matching taint. A taint repels every pod that does not tolerate it.
To keep runners on dedicated nodes, label and taint those nodes, then add both settings to the pod template. The selector pulls the pods to the right nodes, and the toleration lets them in. Neither one does both jobs alone.
kubectl label nodes <node-name> workload=ci-runners
kubectl taint nodes <node-name> dedicated=ci-runners:NoScheduletemplate:
spec:
nodeSelector:
workload: ci-runners
tolerations:
- key: dedicated
operator: Equal
value: ci-runners
effect: NoSchedule
containers:
- name: runner
image: ghcr.io/actions/actions-runner:latest
command: ["/home/runner/run.sh"]Common errors
- Pods stuck in
Pending. Runkubectl describe pod <name> -n arc-runnersand read the Events section. Messages such asInsufficient memoryornode(s) had untolerated taintshow which check failed. - Runners on the wrong nodes. A toleration alone does not restrict placement. Add the
nodeSelectoras well. - Jobs killed with exit code 137. This usually means an OOM kill. Raise the memory limit or reduce build parallelism.
- Overriding the template drops defaults. If you replace the
containerslist, keep therunnercontainer name, itscommand, and any mode-specific settings, or the pod will not start correctly.
Exercise
A runner pod stays Pending. The events say "0/5 nodes are available: 5 node(s) had untolerated taint {dedicated: ci-runners}". What is missing from the scale set values, and what else should you add so runners stay on those nodes?
Show answer
The pod template has no toleration for the dedicated=ci-runners:NoSchedule taint. Add a matching entry under template.spec.tolerations. Also add a nodeSelector that matches the label on the dedicated nodes, because a toleration only permits scheduling on tainted nodes and does not require it.