Runner
A CI/CD runner is the machine or container that executes pipeline jobs, either managed by the CI provider or self-hosted on your own infrastructure.
Understanding CI/CD Runners
What Is a Runner and What Types Exist
A runner is the worker that actually runs a job's steps. Hosted runners are ephemeral virtual machines managed by the provider and discarded after each job. Self-hosted runners are machines you run, such as servers, VMs, or Kubernetes pods, that register with the CI platform and pick up queued jobs. Choose self-hosted for private network access, special hardware, or cost at scale.
Hosted vs Self-Hosted
| Aspect | Hosted | Self-hosted |
|---|---|---|
| Setup | None | You install and maintain |
| State | Fresh per job | Can persist between jobs |
| Private network | Not reachable | Reachable |
Selecting Runners by Label
jobs: build: runs-on: ubuntu-latest # hosted deploy-prod: runs-on: [self-hosted, linux, payments-vpc] # your runner in the VPCRegistering a Self-Hosted Runner
# Download the current runner release from the repo's Settings > Actions > Runners pagemkdir actions-runner && cd actions-runner # Configure it (token comes from GitHub settings)./config.sh \ --url https://github.com/razorpay/payment-api \ --token RUNNER_TOKEN \ --labels linux,payments-vpc \ --ephemeral # Install as a servicesudo ./svc.sh installsudo ./svc.sh start # GitLab runner registrationgitlab-runner register --url https://gitlab.com --token REGISTRATION_TOKEN --executor docker --docker-image alpine:latestThe --ephemeral flag makes the runner take one job and then deregister, so each job gets a clean machine. Pair it with autoscaling, for example Actions Runner Controller on Kubernetes.
Troubleshooting
| Symptom | Check | What to look for |
|---|---|---|
| Job queued, not starting | Runner availability | All busy or offline |
| Runner offline | ./svc.sh status |
Service stopped or token expired |
| Tool not found | Runner image | Missing software for this label |
| Wrong runner picks job | Labels | Labels do not match exactly |
TipLabel runners by capability, such as
arm64orhigh-cpu, not by machine name, so you can scale horizontally.
RememberHosted runners start clean every time. Install tools per job with setup actions or a container.
SecurityDo not attach self-hosted runners to public repositories without strict controls. A malicious pull request can run code on a machine that may hold production credentials.
Common MistakeHand-installing tools on a long-lived runner until it becomes a snowflake. Keep runners stateless and reproducible with containers or ephemeral images.
Frequently Asked Questions
When should I use self-hosted runners?
When jobs need private network resources, special hardware such as GPUs or ARM, licensed software, or when hosted minutes become expensive. Otherwise hosted runners are easier and isolated per job.
What security risk is specific to self-hosted runners?
They can persist between jobs and execute code from pull requests, so a malicious PR on a public repository could leave malware or steal secrets. Use them for private repos or require approval for external contributors.
What does an ephemeral runner mean?
It handles a single job and is then destroyed or deregistered, which prevents state leaking from one job to the next.