Kubernetes volumes

Merged Zeger-Jan van de Weg requested to merge kubernetes-volumes into master

Continuing the work of @jon-walton, to support Kubernetes volumes.

What does this MR do?

This MR adds basic volume support to the Kubernetes runner. Kubernetes volumes work differently to docker such that it's possible to mount many different types of storage into the container. To reflect this and to make it easy to implement other sources into the runner in the future, I've implemented the source and the container mount as separate config items (the structure is very similar to a kubernetes config file).

For now, only HostPathVolumeSource is supported

An example config.toml would be:

concurrent = 2

  name = "Kubernetes Runner"
  url = "https://gitlab.com/ci"
  token = "TOKEN"
  executor = "kubernetes"
    namespace = "gitlab"
    privileged = true

      name = "docker"
      mount_path = "/var/run/docker.sock"

      name = "docker"
      path = "/var/run/docker.sock"

      name = "cache"
      mount_path = "/cache/"

      name = "cache"
      path = "/tmp/gitlab-ci-cache/"

    Insecure = false

Any mounts configured must have a matching volumes

Why was this MR needed?

I have a requirement to bind the docker socket into the build pods because I do not want to use docker:dind. Binding the socket gains me local image caching and no risk of name conflicts because kubernetes appends a random string to each pod's name

Are there points in the code the reviewer needs to double check?

This is my first look into golang, so please let me know if I've done anything wrong. If the general direction is sound, I will go ahead and add documentation.

Does this MR meet the acceptance criteria?

  • Documentation created/updated
  • Tests
    • Added for this feature/bug
    • All builds are passing
  • Branch has no merge conflicts with master (if you do - rebase it please)

What are the relevant issue numbers?

Closes #1876 (closed), #1759 (closed), !331 (closed)

Edited by Zeger-Jan van de Weg