Setting up GitLab Runner on GCP VM Instance

Last updated - May 06, 2023Author Rabra Hierpa
illustration with a man watching two screens

If you’re using GitLab CI/CD to automate your software development workflow, you’ll need to set up one or more GitLab Runners to execute your CI/CD pipelines. A GitLab Runner is a lightweight agent that runs on a machine and listens for jobs from a GitLab instance.

In this post, we’ll show you how to set up a GitLab Runner on a GCP virtual machine (VM) running Ubuntu 18.04. This will allow you to run your CI/CD pipelines on a dedicated VM in the cloud, which can help improve the reliability and performance of your pipelines.

To get started, you’ll need to create a GCP VM and install GitLab Runner on it. You can follow these general steps:

Step 1: Log in to your Google Cloud Platform console and navigate to the Compute Engine page.’

Step 2: Click on the “Create Instance” button to create a new VM instance.

Step 3: In the “Basics” tab, enter a name for your instance and select the desired region and zone.

Step 4: In the “Machine Configuration” section, select the “2 vCPUs” option and set the memory to “8 GB” under the General-Purpose tab.

Step 5: Choose a boot disk image that you want to use for your instance. You can select one of the pre-built images from Google or you can upload your own custom image.

Step 6: Under the “Firewall” section, select the network tags for your instance. Make sure to allow HTTP and HTTPS traffic.

Once the instance is created, you can log in to it and start using it. You can install any software and configure it as per your requirements.

Setting up GitLab Runner on the Instance

# Download the binary for your system
sudo curl -L --output /usr/local/bin/gitlab-runner \

# Give it permission to execute
sudo chmod +x /usr/local/bin/gitlab-runner

# Create a GitLab Runner user
sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash

# Install and run as a service
sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
sudo gitlab-runner start

After gitlab-runner is install on your instance register your gitlab-runner using the following command

sudo gitlab-runner register --url --registration-token $REGISTRATION_TOKEN

When you register your gitlab-runner make sure it matches the tags on your gitlab-ci.yml file so that the runner would be able to pick up jobs that are specified by the tags defined on your configuration. Also make sure that you select docker as your executor.


I am Rabra Hierpa, a Software Engineer, GIS Developer, and FOSS enthusiast!



YouTube IconTiktok IconLinkedin IconGitHub IconTwitter IconFacebook IconOpenStreetMap Icon
© 2024 Made with ❤ by Rabra Hierpa