Search code examples
gitlab-cigitlab-ci-runner

Where should the GitLab Runner actually run?


I'm trying to set up a Continuous Integration/Deployment pipeline using GitLab CI, and I'm struggling to understand (and not really finding any information in the documentation) about where a GitLab Runner should actually live. Should I run one on my local machine? Should there be a server that just hosts the Runner?

From my understanding, the purpose of the runner is to execute the jobs which are triggered by a commit. Upon commit, the GitLab Runner will try and execute the jobs defined in the .gitlab-ci.yml file.

I am aware that these jobs can do numerous things, but as a starting point, I would simply like to SSH into a server, and deploy my code.

My confusion comes from not understanding what the recommended place the Runner should actually live and run is? It seems potentially problematic to store it on my local machine as this would rely on my machine being on and available for deployments to work. Does this mean we'd require another server just for the runner itself?


Solution

  • Where? Well, whenever you want. Gitlab runner operate in pull mode, that is the runner contacts the web api of the server and checks for jobs, it also contacts the server to upload all the logs. That means that the gitlab runner can be behind NAT or it can be very dynamic.

    The SSH executor runs by connection over SSH from the runner to the target. That means that the machine with the runner has to have a route to the target server.

    As for where you should run the runners? Well, that's up to you. Maybe you need to occasionally run it on your laptop to connect to local VM, maybe you need a beefy machine in the cloud, maybe you want to run a cheap machine on old server in your basement. Maybe all three.