Skip to content

Latest commit

 

History

History
119 lines (89 loc) · 5.51 KB

gitlab-runner.md

File metadata and controls

119 lines (89 loc) · 5.51 KB

Overview

This feature of mapt allows you to set up hosts deployed by it as GitLab Runners, which can then be directly used for running GitLab CI/CD jobs. It benefits from all the existing features that mapt already provides, allowing you to create self-hosted runners that can be used for different QE scenarios.

Providers and Platforms

Currently, it allows you to create self-hosted GitLab runners on AWS (Fedora, RHEL, Windows Server, macOS) and Azure (RHEL, Windows Desktop).

Prerequisite

To register a GitLab Runner, you need an access token with create_runner and manage_runner scopes. There are two options:

Option 1: Project Access Token (Recommended)

Project Access Tokens are scoped to a specific project, making them more secure than personal tokens.

Requirements:

  • GitLab Premium/Ultimate (on GitLab.com)
  • OR self-managed GitLab instance (version 13+)

Steps:

  1. Go to your project → Settings → Access Tokens
  2. Create a new token with:
    • Token name: mapt-runner
    • Role: Maintainer or Owner
    • Scopes: Select create_runner and manage_runner
    • Expiration: Set according to your needs
  3. Click Create project access token
  4. Copy the token immediately

Option 2: Personal Access Token (Fallback)

If Project Access Tokens are not available, use a Personal Access Token:

  1. Go to User Settings → Access Tokens
  2. Create a new token with:
    • Token name: mapt-runner-token
    • Scopes: Select create_runner and manage_runner
    • Expiration: Set according to your needs
  3. Click Create personal access token
  4. Copy the token immediately

Getting Project or Group ID

You also need either a Project ID or Group ID:

  • Project ID: Go to your project → Settings → General (displayed at the top)
  • Group ID: Go to your group → Settings → General (displayed at the top)

NOTE: For Group Runners with Group Access Tokens, you'll need GitLab Premium/Ultimate on GitLab.com or a self-managed instance.

Operations

After obtaining the token and the project/group ID, you can deploy a runner using the appropriate flags.

Required flags:

  • --glrunner-token - Your GitLab access token (project or personal)
  • --glrunner-url - GitLab instance URL (e.g., https://gitlab.com)
  • --glrunner-project-id OR --glrunner-group-id - Either project or group ID (not both)

Optional flags:

  • --glrunner-tags - Comma-separated tags (e.g., aws,mapt,fedora)
  • --glrunner-http-proxy - Proxy URL for the jobs when the host network needs an egress proxy (e.g., http://proxy.example.com:3128). It is written to the runner's environment as HTTP_PROXY, HTTPS_PROXY, http_proxy and https_proxy
  • --glrunner-no-proxy - Comma-separated host names, domains or IP addresses the jobs reach directly, written as NO_PROXY and no_proxy. Requires --glrunner-http-proxy. CIDR ranges such as 10.0.0.0/8 are rejected, because some clients (curl on RHEL 9, for example) ignore them without an error

Both proxy flags need --glrunner-token; without it no runner is set up and they are ignored.

NOTE: The proxy settings only reach the jobs. Downloading and registering the runner, the runner service and the image pulls made by Podman on the host use the host's own proxy configuration; see #974.

NOTE: The proxy URL, including any credentials in it, ends up in:

  • the instance user data, which any process on the host can read from the cloud's instance metadata service. With --glrunner-unsecure, jobs run as the host login user, so job code can read it too
  • the Pulumi state in the --backed-url backend, because the user data is a resource input
  • /var/lib/cloud/instance/user-data.txt on Linux hosts that use cloud-init
  • /etc/gitlab-runner/config.toml

Prefer a proxy that allows clients by source address, or a credential used only for this runner. Percent-encode special characters such as @, :, /, ? and # in a user name or password.

To deploy a Fedora runner on AWS behind an egress proxy:

mapt aws fedora create --spot \
    --glrunner-token="glpat-xxxxxxxxxxxxxxxxxxxx" \
    --glrunner-url="https://gitlab.com" \
    --glrunner-project-id="12345678" \
    --glrunner-http-proxy="http://proxy.example.com:3128" \
    --glrunner-no-proxy="localhost,127.0.0.1,.internal.example.com" \
    --project-name mapt-fedora-aws \
    --backed-url file:///Users/tester/workspace \
    --conn-details-output /Users/tester/workspace/conn-details

To deploy a Fedora runner on AWS as a project runner:

mapt aws fedora create --spot \
    --glrunner-token="glpat-xxxxxxxxxxxxxxxxxxxx" \
    --glrunner-url="https://gitlab.com" \
    --glrunner-project-id="12345678" \
    --glrunner-tags="aws,fedora,mapt" \
    --project-name mapt-fedora-aws \
    --backed-url file:///Users/tester/workspace \
    --conn-details-output /Users/tester/workspace/conn-details

To deploy a RHEL runner on Azure as a group runner:

mapt azure rhel create --spot \
    --glrunner-token="glpat-xxxxxxxxxxxxxxxxxxxx" \
    --glrunner-url="https://gitlab.com" \
    --glrunner-group-id="87654321" \
    --glrunner-tags="azure,rhel,mapt" \
    --project-name mapt-rhel-azure \
    --backed-url file:///Users/tester/workspace \
    --conn-details-output /Users/tester/workspace/conn-details

NOTE: If no tags are provided with --glrunner-tags, the runner can run untagged jobs. If tags are provided, the runner only runs jobs matching those tags.