Github runners on nomad
I’ve been on a nomad roll recently - I managed to get a gitlab runner installed in my nomad cluster. The offical github docs has some interactive instructions on setting up a runner, but if you poke around a little there are some instructions for unattended installs:
Examples:
Check GitHub server network connectivity:
./run.sh --check --url <url> --pat <pat>
Configure a runner non-interactively:
./config.sh --unattended --url <url> --token <token>
Configure a runner non-interactively, replacing any existing runner with the same name:
./config.sh --unattended --url <url> --token <token> --replace [--name <name>]
Configure a runner non-interactively with three extra labels:
./config.sh --unattended --url <url> --token <token> --labels L1,L2,L3
This line was good enough for me:
./config.sh --unattended --url <url> --token <token> --replace [--name <name>]
Here’s what the final manifest looks like:
job "github-runner-NAME" {
datacenters = ["atx01"]
type = "service"
group "github-runner-NAME" {
ephemeral_disk {
migrate = true
size = 500
sticky = true
}
task "github-runner-NAME" {
driver = "exec"
config {
command = "/bin/sh"
args = ["-c", "cd alloc/data && ./config.sh --unattended --url URLHERE --token TOKENHERE --replace --name nomad-runner-01 && ./run.sh && sleep 5;"]
}
artifact {
source = "https://github.com/actions/runner/releases/download/v2.277.1/actions-runner-linux-x64-2.277.1.tar.gz"
destination = "alloc/data"
}
resources {
cpu = 2000
memory = 1492
}
}
}
}
This is a bit nicer than having to deal with systemd configuration in salt - I don’t really care where my runners run so it’s not necessary that they’re statically defined somewhere. This also should theoretically make it way easier to spin up additional nodes as well…
I love docker, but I’ll say it’s definitely way easier to go from command line to a nomad job with the exec driver. At some point once I have my k8s cluster setup, I’ll try messing around with a github runner there (a cursory google search shows a bunch of hits).