[tutorial] Run a GitLab Runner that submits SLURM jobs on Baobab

How to run a GitLab Runner that submits SLURM jobs

This document explains how to create a GitLab runner and configure it so that your CI/CD jobs are executed on the cluster using SLURM.


1. Create a token for registering a new GitLab runner

In your GitLab project, go to:

Settings → CI/CD → Runners → New project runner

Generate a new runner token:

Specify a runner tag.

Jobs that specify this tag in .gitlab-ci.yml will be executed by this runner:

Be sure to copy the token displayed at the end of the runner creation process (2).
This token is shown only once and will be required later:


2. Clone the slurm-gitlab-executor project

On login1, run:

git clone https://github.com/Algebraic-Programming/slurm-gitlab-executor.git slurm-gitlab-executor
cd slurm-gitlab-executor

3. Register your GitLab runner

From the cluster terminal, run (replace the token):

gitlab-runner register --name slurm-gitlab-executor --url https://gitlab.unige.ch --token glrt-<token-from-step-above>

4. Generate a new runner configuration

Run:

./generate-config.sh "/home/sagon/.gitlab-runner/config.toml" > config.toml

Then adjust the generated config file as needed. For example:

[[...]
    builds_dir = "/home/sagon/slurm-gitlab-executor/wd/builds"
    cache_dir = "/home/sagon/slurm-gitlab-executor/wd/cache"
[...]

5. Start the runner on login1

Run:

gitlab-runner run --config config.toml

6. Add a .gitlab-ci.yml to your project

In your GitLab repository, add a .gitlab-ci.yml file.
An example using SLURM is available here.


7. Launch a pipeline

In GitLab:

Build • Pipelines • New pipeline

You can now trigger a pipeline and configure SLURM parameters depending on your workflow.

Comments welcome!

1 Like

Hi Yann,

Thanks a lot for the great tutorial.

Some of my CI jobs need to build container images on compute nodes using buildah inside Apptainer with --fakeroot. Currently Apptainer falls back to a root-mapped namespace because my user has no subuid/subgid entries:

INFO: User not listed in /etc/subuid, trying root-mapped namespace

This causes lchown failures during image layer extraction since only UID/GID 0 is mapped:

lchown /etc/gshadow: invalid argument (requested 0:42)

Request: Can you please add subuid/subgid entries for my user or all users on login and compute nodes?

# /etc/subuid and /etc/subgid

username:100000:65536

I saw you had already done something similar in Feb 2022 on login2.baobab (see forum thread about podman subuid errors: https://hpc-community.unige.ch/t/solved-cannot-login-to-login2/260).

Thanks!

Maroun

Dear @Maroun.BouSleiman thanks for the notification. We just figured out that it wasn’t done automatically by our scripts. This is now the case for subuid and subgid.

Best regards

Yann

Thank you Yann.

It works perfectly now. Docker builds are now possible on the HPC with buildah.

Cheers,

Maroun