Published in


Setup GitLab runner on AWS-ec2

In this article, we are gonna set up a GitLab runner on the amazon ec2 instance.

What is GitLab?

Gitlab is a simple, understanding, and efficient platform for DevOps platform. There are six core values of GitLab 🤝 Collaboration, 📈 Results, ⏱️ Efficiency, 🌐 Diversity, Inclusion & Belonging.

What are Gitlab runners? 🤔

GitLab runner is like a kitchen 🍳 in our home, We use it to cook something. In DevOps, it’s called an agent/Slave. It’s basically an agent that runs your CI/CD that comes from GitLab. When we set up a runner that creates a communication between your GitLab and the machine where GitLab Runner is installed.

For example⬇️,

1 . We need to build a container and push it to a repository.

2. Run an npm build and copy the build folder to a remote location.

3. Perform some remote execution using ssh.

Let’s start setting up the GitLab runner👷,

Here, We are going to use a Ubuntu ec2 instance .

Step 1: Add the repository of Gitlab-runner.

curl -L "" | sudo bash

This will add an official GitLab repository.

Step 2: Install GitLab Runner on ubuntu

The below commands to install the latest GitLab runner.⬇️

sudo apt-get update 
sudo apt-get install gitlab-runner

Step 3: Check if it’s installed correctly or not.

sudo gitlab-runner -version

After running the above command you can view the output shown below.

Version:      14.8.2
Git revision: c6e7e194
Git branch: 14-8-stable
GO version: go1.17.7
Built: 2022-03-01T17:18:25+0000
OS/Arch: linux/amd64

Note📝: This may differ in your case

To check the Gitlab runner status

sudo gitlab-runner status


Runtime platform  
arch=amd64 os=linux pid=284992 revision=c6e7e194 version=14.8.2
gitlab-runner: Service is running

Step 4: Register a Gitlab Runner to Gitlab on Ubuntu

  1. Login to the GitLab account. Go to the project and its setting.

Gitlab ➡️Login ➡️project ➡️ Settings ➡️ CI/CD ➡️ runners


👀 Expand the runner tab and you’ll see two things: the URL and the
registration token. 👀

Keep a copy of them as we are going to use them to register the runner.

Note: You should disable the Public runner so all the jobs tents towards the private runner. i.e Ubuntu.

Now, Let’s register it.

sudo gitlab-runner register

Use the above command to start the registration process.

You’ll be prompted for 6 inputs.

  1. Enter the GitLab instance URL:
  2. Enter the registration token: We copied it from the project setting above. These are private and Do not share with anyone.
  3. Enter a description for the runner: Your choice
  4. Enter tags for the runner (comma-separated):

These tags are most important as we are gonna use them in the pipelines to uniquely identify the runner

5. Enter an optional maintenance note for the runner: Your choice

6. Enter an executor:

Note: the executor might change use-case to use-case. For example

A. We need a docker container and perform an action on that, In this case, we use “docker” as executor.

B. We need to shell, In this case, we use “shell” as executor.

Step 5: Let’s start the GitLab-runner.

sudo gitlab-runner start

Step 6: Check in the Gitlab console

⭐ You can see the available runner in GitLab

We have successfully installed and registered the GitLab runner on the Ubuntu ec2 instance.

Thanks for reading!




A Bespoke Engineering Studio

Recommended from Medium

[8] Complete ODDS SHINY soon after 10960

Agile Introspection Asking Your Software Development Team This One Question

How to Speed Up Your Migration to the Cloud with DevOps

Build your own operating system #6_integrate_user_modes

Hello everyone,

Run GUI Application Inside Docker Container..

Developing a DevOps tool for SSO with G Suite on AWS

Build a Goodreads Clone with Spring Boot and Astra DB — Part 3

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
suyog shinde

suyog shinde


More from Medium

How to Setup a Jenkins to Dockerhub Pipeline with Multi-Arch Images

How to use Jenkins to deploy apps directly from GitHub to AWS EC2

Getting Started Page for Jenkins

CICD with Jenkins Pipelines Running in Docker

All you need to know about Auth in the Web. Identity and Access Management.