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 larger workloads with more CPU and memory than GitLab shared runners
- Jobs run directly on DSRI infrastructure using the Kubernetes executor
- Define your pipeline in a simple
.gitlab-ci.ymlfile 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
Before deploying a GitLab runner, contact us via the Topdesk Form or by emailing the RCS team.
- Access to a DSRI project (
oc project my-project) - Access to a GitLab project on gitlab.maastrichtuniversity.nl
Get a GitLab Runner token
- Go to your GitLab project on gitlab.maastrichtuniversity.nl
- Navigate to Settings → CI/CD and expand Runners
If you don't see the CI/CD option in Settings, go to Settings → General → Visibility, project features, permissions and enable CI/CD pipelines.
- Click "New project runner"
- Add the tag
openshift - Click Create runner
- Copy the token (it starts with
glrt-)
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]
[runners.kubernetes.volumes]
[[runners.kubernetes.volumes.empty_dir]]
name = "empty-dir"
mount_path = "/"
medium = "Memory"
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
serviceAccount: gitlab-runner-jobs
Apply it:
oc create -f gitlab-runner.yaml
4. Verify the deployment
oc get pods
oc get runner
You should see the runner pod running. 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!"
Always specify an image in your job. The runner requires a Docker image to run jobs in. If no image is specified the job will fail.
Commit the file and GitLab will automatically trigger a pipeline. Go to CI/CD → Pipelines in your project to monitor the job. Once confirmed working, replace the example script with your own commands.
Clean up
To remove the runner:
oc delete -f gitlab-runner.yaml
oc delete configmap custom-config-toml
oc delete secret gitlab-runner-secret
See also
- GitLab Runner operator documentation: https://docs.gitlab.com/runner/install/operator.html
- GitLab CI/CD documentation: https://docs.gitlab.com/ee/ci/
- GitLab CI/CD keyword reference: https://docs.gitlab.com/ee/ci/yaml/