Skip to content

Added SubPath support to Kubernetes volume definitions

What does this MR do?

Implementation for Issue #3223 (closed)

Why was this MR needed?

To provide SubPath support to Kubernetes volume mounts. By exposing the SubPath attribute, one can create multiple isolated volume mounts from a single volume. In my case, I want to mount multiple paths within the GitLab executor container to a local SSD hostPath volume.

What's the best way to test this MR?

I updated the unit tests, and I manually tested in my local environment by creating multiple volume mounts with the same volume source, distinguished by the SubPath attribute. Since there is currently no ability to separate volume declarations from volume mount declarations, my config.toml looks like this:

  template.toml: |
    [[runners]]
      [runners.kubernetes]
        [runners.kubernetes.volumes]
          [[runners.kubernetes.volumes.host_path]]
            name = "ssd0-gitlab"
            host_path = "/mnt/disks/ssd0"
            sub_path = "gitlab"
            mount_path = "/home/gitlab"
          [[runners.kubernetes.volumes.host_path]]
            name = "ssd0-tmp"
            host_path = "/mnt/disks/ssd0"
            sub_path = "tmp"
            mount_path = "/tmp"

With this configuration, I'm able to mount /tmp and /home/gitlab to separate directories within the local SSD volume.

See test run in !2424 (comment 429733452)

What are the relevant issue numbers?

#3223 (closed)

Edited by Pedro Pombeiro

Merge request reports