Skip to main content

Deploy GitLab Runners

Deploy a GitLab Runner on the DSRI to run your GitLab CI/CD pipeline jobs on the DSRI.

Why use a DSRI GitLab runner?​

  • Run your CI/CD jobs on DSRI infrastructure, with your own dedicated runner
  • Jobs run directly on DSRI using the Kubernetes executor
  • Define your pipeline in a simple .gitlab-ci.yml file in your repository
  • Use any Docker image as your job environment
  • Integrate with your existing GitLab repositories at gitlab.maastrichtuniversity.nl

For more information about GitLab CI/CD, go to https://docs.gitlab.com/ee/ci/

Prerequisites​

Request access first

Before deploying a GitLab runner, contact us via the Topdesk Form or by emailing the RCS team. We will prepare your DSRI project for a runner and let you know when it's ready.

Get a GitLab Runner token​

  1. Go to your GitLab project on gitlab.maastrichtuniversity.nl
  2. Navigate to Settings → CI/CD and expand Runners
CI/CD must be enabled

If you don't see the CI/CD option in Settings, go to Settings → General → Visibility, project features, permissions and enable CI/CD pipelines.

  1. Click Create project runner
  2. Add the tag openshift
  3. Click Create runner
  4. Copy the runner authentication token (it starts with glrt-). It is only shown once. You can ignore the gitlab-runner register instructions on that page, they are not needed on DSRI.
Keep your token private

Anyone with this token can run jobs as your runner. Only store it in the secret below.

Deploy the runner​

Make sure you are in the correct project:

oc project my-project

1. Create the token secret​

oc create secret generic gitlab-runner-secret \
--from-literal=runner-token=<your-glrt-token>

2. Create the runner configuration​

Create a file called config.toml:

[[runners]]
executor = "kubernetes"
[runners.kubernetes]
service_account = "anyuid"

Create a ConfigMap from it:

oc create configmap custom-config-toml --from-file config.toml=config.toml

3. Create the GitLab Runner resource​

Create a file called gitlab-runner.yaml:

apiVersion: apps.gitlab.com/v1beta2
kind: Runner
metadata:
name: gitlab-runner
spec:
gitlabUrl: https://gitlab.maastrichtuniversity.nl
token: gitlab-runner-secret
config: custom-config-toml
tags: openshift
buildImage: alpine
podSpec:
- name: resources
patchType: strategic
patch: |
{"containers":[{"name":"runner","resources":{
"requests":{"cpu":"100m","memory":"128Mi","ephemeral-storage":"1Gi"},
"limits":{"cpu":"500m","memory":"512Mi","ephemeral-storage":"2Gi"}}}]}

The podSpec section sets CPU, memory and storage limits for the runner itself. This is required on DSRI: without it, the runner will not start.

Apply it:

oc create -f gitlab-runner.yaml
Working in the web terminal?

You can create both files without an editor by pasting a block like this, including the EOF line at the end:

cat > config.toml <<'EOF'
[[runners]]
executor = "kubernetes"
[runners.kubernetes]
service_account = "anyuid"
EOF

Do the same for gitlab-runner.yaml: start with cat > gitlab-runner.yaml <<'EOF', paste the YAML, and end with EOF.

4. Verify the deployment​

oc get pods
oc get runner

You should see the runner pod running. It can take a minute before it shows as ready (1/1). Then confirm the runner registered on GitLab by going to Settings → CI/CD → Runners in your GitLab project. The runner should appear with status Online.

Use the runner in a pipeline​

In your GitLab repository, create a .gitlab-ci.yml file and set tags to target your DSRI runner. Here is a simple example to verify your runner is working:

stages:
- test

test-dsri-runner:
stage: test
image: alpine
tags:
- openshift
script:
- echo "Runner is working on DSRI!"
tip
  • Every job must have the tag openshift. Jobs without it will stay pending, because no runner picks them up.
  • Set an image for each job. If you don't, the job runs in alpine, which may not have the tools you need.

Commit the file and GitLab will automatically trigger a pipeline. Go to Build → Pipelines in your project to monitor the job. Once confirmed working, replace the example script with your own commands.

Use your runner in other projects​

You don't need to deploy a new runner for every GitLab project. You can enable the same runner for your other projects:

  1. In the other GitLab project, go to Settings → CI/CD and expand Runners
  2. Open the tab Other available project runners
  3. Click the link icon (Enable for this project) next to your runner
  4. Add the tag openshift to the jobs in that project's .gitlab-ci.yml

If your runner doesn't show up in the list, open its settings in your original project (pencil icon) and uncheck Lock to current projects.

Nothing needs to change on DSRI: your runner will pick up jobs from those projects too.

Clean up​

To remove the runner:

oc delete -f gitlab-runner.yaml
oc delete configmap custom-config-toml
oc delete secret gitlab-runner-secret

Then also delete the runner in GitLab under Settings → CI/CD → Runners.

See also​