Skip to content

Unable to expose runner directory to job container

I have deployed a runner in Openshift (v3.11) using this template as a guide: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/f04b5c4443b3a98011577cdd7c9de766a287531e/docker/openshift/runner-template.yml

My issue is I want my runner to expose a host volume to the pipeline. So my runner mounts an Openshift secret to /etc/maven/ on the runner. I am trying to enable the job container to mount /etc/maven on the runner by adding the following to the configMap:

apiVersion: v1
data:
  config.toml: |-
    concurrent = 10
    check_interval = 10
  entrypoint: |
    #!/bin/bash
    set -xe
    cp /scripts/config.toml /etc/gitlab-runner/
    # Register the runner
    /entrypoint register --non-interactive \
      --url $GITLAB_URL \
      --run-untagged \
      --kubernetes-privileged \
      --registration-token $REGISTRATION_TOKEN \
      --name "k8s_runner_foo" \
      --executor kubernetes
    # Add extra config
    cat  /scripts/extraconfig.yaml >> /etc/gitlab-runner/config.toml
    # Start the runner
    /entrypoint run --user=gitlab-runner \
      --working-directory=/home/gitlab-runner
  extraconfig.yaml: |2-
        [[runners.kubernetes.volumes.host_path]]
          name = "maven-settings"
          mount_path = "/etc/maven"
          read_only = true
          host_path = "/etc/maven"
kind: ConfigMap

I can't seem to get this to work though. Running a ls on /etc/ during the pipeline does not show the mounted volume. Or perhaps I'm completely misunderstanding what this is supposed to be doing?