What is GitLab, GitLab Runner?

A comprehensive guide to GitLab, GitLab Runner installation and configuration

Featured image



Overview

Let’s explore GitLab, a comprehensive DevOps platform that provides tools for software development, deployment, and collaboration. GitLab helps teams efficiently plan, create, test, and deploy their software projects.

What is GitLab?

GitLab is a web-based DevOps platform that provides an all-in-one solution for software development and collaboration. It offers tools and features that help teams plan, create, build, test, and deploy software projects more efficiently.

GitLab combines version control, issue tracking, CI/CD pipelines, and more into a single, integrated platform.


Key Features:

GitLab Featrue Diagram



Installation Guide (Ubuntu 18.04/20.04/22.04)

1️⃣ System Update & Package Installation

# Update System
sudo apt update
sudo apt upgrade -y

# Install Required Packages
sudo apt install -y ca-certificates curl openssh-server tzdata

2️⃣ Add GitLab CE Repository

# Install Dependencies
sudo apt install curl debian-archive-keyring lsb-release ca-certificates \
    apt-transport-https software-properties-common -y

# Add GitLab Repository
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash

3️⃣ Install and Configure GitLab

# Install GitLab CE
sudo EXTERNAL_URL="https://gitlab.example.com/" apt-get install gitlab-ce

# Configure SSL (Cloud Environment)
echo "letsencrypt['enable'] = false" | sudo tee -a /etc/gitlab/gitlab.rb
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart



Important Directories

🗄️ Key Directories
  • /var/opt/gitlab/gitlab-rails/shared/lfs-objects
    Efficiently handles Git Large File Storage (LFS) objects, reducing repository size while enabling the management of large binary files.
  • /var/opt/gitlab/git-data
    Houses actual Git repositories, serving as the root directory for all project-related data and repository operations.


# Example Storage Mount
/dev/xvdb1  2.0T  310G  1.6T  17%  /var/opt/gitlab/gitlab-rails/shared/lfs-objects
/dev/xvdc1  984G  273G  661G  30%  /var/opt/gitlab/git-data



Basic Management Commands

# Reconfigure GitLab
sudo gitlab-ctl reconfigure

# Restart GitLab
sudo gitlab-ctl restart

# Check GitLab Status
sudo gitlab-ctl status

# View Initial Root Password
sudo cat /etc/gitlab/initial_root_password



GitLab Runner

🔍 What is GitLab Runner?

GitLab Runner is a CI tool that works with GitLab to automatically build, test, and deploy code changes. It’s an open-source project that executes jobs in CI/CD pipelines on systems called Runners.

GitLab Runner can be installed on various operating systems and platforms, including Linux, macOS, Windows, and Kubernetes clusters.


How GitLab Runner Works:

  1. When code changes are pushed to a GitLab repository with CI/CD pipeline configured
  2. GitLab creates a new pipeline with one or more jobs
  3. GitLab Runner periodically checks for new jobs
  4. Runner executes the job steps defined in .gitlab-ci.yml
  5. Runner sends real-time updates and logs back to GitLab


Types of Runners

🔄 Runner Categories
  • Shared Runners
    Available to all projects in a GitLab instance, managed by GitLab administrators. Ideal for common build environments.
  • Group Runners
    Dedicated to specific project groups and managed by group administrators. Provides better resource control for group projects.
  • Specific Runners
    Dedicated to single projects, also known as Project Runners. Offers exclusive resources for specific projects.


Installation Guide (Helm)

1️⃣ Prerequisites

# Add GitLab Helm Repository
helm repo add gitlab https://charts.gitlab.io/
helm repo update

2️⃣ Create values.yaml

3️⃣ Install GitLab Runner

# Create namespace
kubectl create namespace gitlab-runner

# Install Runner
helm install gitlab-runner -n gitlab-runner -f values.yaml gitlab/gitlab-runner

# Upgrade Runner
helm upgrade gitlab-runner -n gitlab-runner -f values.yaml gitlab/gitlab-runner



Reference