Search code examples
gitlabcicd

How often does Gitlab Runner connect to gitlab.com?


I'm new to CI/CD. I installed Gitlab Runner on my VPS for my project. The first pipeline was successfully passed after the push to the master branch. Questions:

  1. Gitlab Runner does not listen to any port. Instead, it connects to the Gitlab server itself and checks if there are tasks for it. Is that true?
  2. If so, how often does Gitlab Runner connect to gitlab.com?
  3. Is it dangerous to keep Gitlab Runner and the project on the same VPS?

Solution

  • Gitlab Runner does not listen to any port. Instead, it connects to the Gitlab server itself and checks if there are tasks for it. Is that true?

    Yes. It is a "pull" mechanism exclusively, as far as the jobs go. Though the runner may open ports for additional functionality, such as the session server.

    If so, how often does Gitlab Runner connect to gitlab.com?

    By default, every 3 seconds to check for new jobs (assuming the concurrency limit has not been reached). This can be configured through the check_interval configuration

    Is it dangerous to keep Gitlab Runner and the project on the same VPS?

    It can be, so this should be avoided where possible. The degree of danger depends somewhat on which executor you use and how you configure your server.

    The file system of your GitLab server is extremely sensitive; it contains many critical secrets and operational components that should not be exposed to anyone (including CI jobs). Besides this, jobs would also have the potential to cause performance problems -- if a job uses too much memory/cpu/IO/etc., it could cause resource contention and harm/crash your other GitLab components on the server.

    You might be able to get away with a single VPS if you deploy the server and runner as separate containers with a Docker or Helm deployment of GitLab and the runner on the VPS host; you can use separate logical Docker volumes and set resource constraints via Docker... but there is still some additional risk in such a scenario and configuration mistakes (which may be easier to make than one might think) can have serious consequences.