Using the GitLab Runner chart

The GitLab Runner subchart provides a GitLab Runner for running CI jobs. It is enabled by default and should work out of the box with support for caching using s3 compatible object storage.

Requirements

This chart depends on the shared-secrets Job to populate its registrationToken for automatic registration. If you intend to run this chart as a stand-alone chart with an existing GitLab instance then you will need to manually set the registrationToken in the gitlab-runner secret to be equal to that displayed by the running GitLab instance.

Configuration

There are no required settings, it should work out of the box if you deploy all of the charts together.

Deploying a stand-alone runner

By default we do infer gitlabUrl, automatically generate a registration token, and generate it through the migrations chart. This behavior will not work if you intend to deploy it with a running GitLab instance.

In this case you will need to set gitlabUrl value to be the URL of the running GitLab instance. You will also need to manually create gitlab-runner secret and fill it with the registrationToken provided by the running GitLab.

Using Docker-in-Docker

In order to run Docker-in-Docker, the runner container needs to be privileged to have access to the needed capabilities. To enable it set the privileged value to true. See the upstream documentation in regards to why this is does not default to true.

Security concerns

Privileged containers have extended capabilities, for example they can mount arbitrary files from the host they run on. Make sure to run the container in an isolated environment such that nothing important runs beside it.

Installation command line options

ParameterDescriptionDefault
gitlab-runner.imageRunner imagegitlab/gitlab-runner:alpine-v10.5.0
gitlab-runner.gitlabUrlURL that the Runner uses to register to GitLab ServerGitLab external URL
gitlab-runner.installInstall the gitlab-runner charttrue
gitlab-runner.imagePullPolicyImage pull policyIfNotPresent
gitlab-runner.init.image.repository initContainer image 
gitlab-runner.init.image.tag initContainer image tag 
gitlab-runner.pullSecretsSecrets for the image repository 
gitlab-runner.unregisterRunnersUnregister all runners before terminationtrue
gitlab-runner.concurrentNumber of concurrent jobs10
gitlab-runner.checkIntervalPolling interval30s
gitlab-runner.rbac.createWhether to create RBAC service accounttrue
gitlab-runner.rbac.clusterWideAccessDeploy containers of jobs cluster-widefalse
gitlab-runner.rbac.serviceAccountNameName of the RBAC service account to createdefault
gitlab-runner.runners.privilegedRun in privileged mode, needed for dind false
gitlab-runner.runners.cache.secretNameSecret to access key and secret key fromgitlab-minio
gitlab-runner.runners.configRunner configuration as stringSee below
gitlab-runner.resources.limits.cpuRunner CPU limit 
gitlab-runner.resources.limits.memoryRunner memory limit 
gitlab-runner.resources.requests.cpuRunner requested CPU 
gitlab-runner.resources.requests.memoryRunner requested memory 

Default runner configuration

The default runner configuration used in the GitLab chart has been customized to use the included MinIO for cache by default. If you are setting the runner config value, you will need to also configure your own cache configuration.

gitlab-runner:
  runners:
    config: |
      [[runners]]
        [runners.kubernetes]
        image = "ubuntu:22.04"
        {{- if .Values.global.minio.enabled }}
        [runners.cache]
          Type = "s3"
          Path = "gitlab-runner"
          Shared = true
          [runners.cache.s3]
            ServerAddress = {{ include "gitlab-runner.cache-tpl.s3ServerAddress" . }}
            BucketName = "runner-cache"
            BucketLocation = "us-east-1"
            Insecure = false
        {{ end }}

Chart configuration examples

Runners configuration to use only custom nameservers (exclude any cluster or host nameservers):

gitlab-runner:
  runners:
    config: |
      [[runners]]
        [runners.kubernetes]
          image = "ubuntu:22.04"
          dns_policy = "none"
        [runners.kubernetes.dns_config]
          nameservers = ["8.8.8.8"]

See the Runner chart additional configuration.