Skip to main content

GitLab Architecture

Updated Jan 17, 2023 ·

Overview

GitLab's architecture includes the GitLab server, runners, and executors, which work together to manage code and automate tasks.

GitLab Server

The GitLab server is the core component that handles the GitLab web interface and the management of projects.

  • Provides access to the GitLab web interface.
  • Manages user permissions and authentication.

There are two types of GitLab servers: GitLab SaaS and GitLab Managed.

  • GitLab SaaS: A cloud-based GitLab service hosted and managed by GitLab.
  • GitLab Managed: A self-hosted version of GitLab that you manage on your infrastructure.

More detailed comparison:

FeatureGitLab SaaSGitLab Managed
HostingHosted and maintained by GitLabHosted and maintained on your own infrastructure
SetupQuick and easy, no server setup requiredRequires server setup and configuration
MaintenanceGitLab handles all updates and maintenanceYou are responsible for updates and maintenance
ControlLimited control over infrastructure and settingsFull control over server settings and configuration
ScalabilityHighly scalable, depending on GitLab's infrastructureScalability depends on your infrastructure capabilities
SecurityManaged by GitLab with standard cloud security measuresFull control over security configuration, can be customized
CostSubscription-based (varies by plan)Initial and ongoing infrastructure costs
Data PrivacyData stored on GitLab's servers (subject to their policies)Full control over data storage and privacy, depending on your infrastructure
Vendor Lock-inPotential lock-in with GitLab's SaaS environmentNo vendor lock-in, as it's self-hosted
Best ForTeams looking for a quick, hassle-free GitLab experience without managing infrastructureOrganizations requiring full control over their GitLab environment, with the ability to customize and manage their infrastructure

GitLab Runners

Runners are responsible for executing jobs defined in the CI/CD pipelines.

  • Can run on various environments (e.g., local or cloud).
  • Connects to GitLab to process jobs.

There are two main options for GitLab runners: Shared runners and Self-Managed runners.

  • Shared Runners

    • Managed by GitLab and available for all projects.
    • Suitable for small to medium projects where custom runner configurations are not required.
  • Self-Managed Runners

    • Installed and managed by the user or organization.
    • Provides more control over the runner's environment and resources.

More detailed comparison:

FeatureShared RunnersSelf-Managed Runners
HostingHosted by GitLabHosted on your own infrastructure
SetupNo setup requiredRequires installation and configuration
MaintenanceManaged by GitLabManaged by you
ControlLimited control over configurationFull control over configuration
ScalabilityScales automaticallyScales within your infrastructure
SecurityShares resources with other projectsIsolated from other projects
CostIncluded in some GitLab tiersMay require additional hardware/software costs
Best forSmall teams, simple needs, ease of use, cost-effectivenessLarge teams, complex needs, control, performance, security

Executors

Runner executors are responsible for running the specific tasks within a job. They can use different environments like Docker or Shell and they execute the commands defined in the job's script section.

There are different types of executors:

  • Shell

    • Executes commands in a shell.
    • Ideal for simple jobs.
  • Docker

    • Runs jobs in containers.
    • Ensures consistent environments.
  • Kubernetes

    • Runs jobs in a Kubernetes cluster.
    • Scales jobs dynamically.
  • Virtual Machine

    • Runs jobs in a virtual machine.
    • Provides strong isolation.
  • SSH

    • Executes jobs remotely via SSH.
    • Useful for remote servers.
  • Custom

    • Custom executor for specific needs.
    • Offers environment flexibility.

This table reflects various executor configurations and their properties for different environments.

ExecutorSSHShellVirtualBoxParallelsDockerKubernetesCustom
Clean build environment for every build✅ (conditional)
Reuse previous clone if it exists✅ (conditional)
Runner file system access protectedconditional
Migrate runner machineconditional
Zero-configuration support for concurrent buildsconditional
Complicated build environmentsconditional
Debugging build problemseasyeasyhardhardmediummediummedium

Working Together

The GitLab server, executor, and runner work together to enable continuous integration and continuous delivery (CI/CD) pipelines.

Steps:

  1. Runner registers registration_token with GitLab server.
  2. GitLab server verifies and returns runner_token to runner.
  3. Runner requests jobs from the GitLab server.
  4. GitLab server assigns job payload with job_token to the runner.
  5. Runner fetches job details and prepares the execution environment.
  6. Runner sends job payload with job_token to the executor.
  7. Executor clones the source and artifacts with job_token.
  8. Executor runs the job on the runner’s machine.
  9. Executor returns job output and status to runner.
  10. Runner updates GitLab server with job output and staus with job_token
  11. GitLab server updates pipeline status.