Search code examples
gitlabgitlab-cigitlab-ci-runner

GitLab deploy to server without SSH


I started learning GitLab CI, so far don't understand GitLab runner concept:

  1. There is a video when a guy installs gitlab-runner on the "prod" server then register it with a token from GitLab, and that's it. His .gitlab-ci.yml is executed on the server via installed and registered runner. Why there is no SSH?
  2. If we connect via SSH and execute deploy commands, why do we need to install gitlab-runner if we can use a shared one?

Solution

  • "It may seem odd to use SSH to run these commands on your server, considering the GitLab runner that executes the commands is the exact same server. Yet it is required, because the runner executes the commands in a Docker container, thus you would deploy inside the container instead of the server if you’d execute the commands without the use of SSH. One could argue that instead of using Docker as a runner executor, you could use the shell executor to run the commands on the host itself. But, that would create a constraint to your pipeline, namely that the runner has to be the same server as the one you want to deploy to. This is not a sustainable and extensible solution because one day you may want to migrate the application to a different server or use a different runner server. In any case it makes sense to use SSH to execute the deployment commands, may it be for technical or migration-related reasons." (с) Mike Nöthiger