Lesson 8 of 9 · 28m
Runner Management: Executors, Isolation, and Scaling
Choose executors by trust boundary, keep runner fleets observable, and avoid the reliability traps of shared mutable build machines.
Runners are production infrastructure, even when they are treated like spare laptops under a desk. They execute arbitrary code from branches, hold credentials, touch caches, and decide whether deployments are possible. The worst runner incidents come from ignoring trust boundaries: one shared shell executor quietly becomes a persistence mechanism for every project it has ever built.
Executors are trust-boundary decisions
shell is fast and simple because jobs run directly on the host. It is also the most dangerous: processes can leak, files persist, and one malicious job can alter the machine for the next job. docker gives stronger workspace isolation. Kubernetes executors scale well but introduce cluster policy questions. Choose based on who can trigger jobs and what credentials jobs can access.
[[runners]]
name = "docker-small"
url = "https://gitlab.example.com"
executor = "docker"
[runners.docker]
image = "alpine:3.20"
privileged = false
volumes = ["/cache"]Privileged docker runners are sometimes needed for docker-in-docker builds, but privileged mode weakens isolation dramatically. Treat it as a separate trust tier, not a convenience flag.
Separate fleets by risk
A common production layout:
- untrusted merge-request runners: no production secrets, limited network, disposable workers
- trusted branch runners: access to registries and deployment credentials
- release runners: narrower, auditable, perhaps manually enabled
- privileged build runners: isolated because docker-in-docker or kernel features require it
Tags route jobs to the right fleet:
deploy-production:
tags: [trusted, production]Tags are routing, not authorization. Protect the variables and environments too.
Capacity is a queueing problem
If pipelines are slow, inspect queue time separately from job duration. A job that waits ten minutes and runs for two is a capacity problem. A job that starts immediately and runs for eighteen is an optimization problem. They have different fixes.
Autoscaling works best with ephemeral machines or pods. It fails when jobs depend on host-local state, large warm caches, or expensive Docker layer pulls. Sometimes a small warm fleet beats a theoretically infinite cold one.
Maintenance and observability
Track runner version, executor type, concurrent count, queue time, job failure rate, disk usage, and cache-hit behavior. Disk pressure is a classic failure: Docker images, old workspaces, and cache archives fill the host until jobs fail with misleading errors.
Rotate runner registration tokens carefully and version-control runner configuration where possible. A runner that exists only because one engineer remembers the install command is already an outage in progress.
Field notes
- Shell executors are mutable shared state with a queue in front.
- Privileged docker runners belong in a separate trust tier.
- Measure queue time and execution time separately before scaling.
- Tags route jobs; they do not enforce security by themselves.
- Ephemeral runners reduce persistence but increase cold-start cost.
Was this lesson helpful?