Introduction
We have a central Gitlab instance hosted by an other department. Additionally I use a gitlab runner (kubernetes executor) in my internal kubernetes cluster to run my CI-Jobs. One of my co-workers asked me if it is possible to mount persistent storage like a nfs-volume into the GitlabCI pipeline to access a large set of sample files for testing purposes.
My first thought was that this kind of setup has to be well-supported by Gitlab, but damn was I wrong. I nearly wasted 2 hours of trial-and-error to get this working setup:
How to add NFS Storage to your GitlabCI Stages
Adding the NFS-volume (and volumeMount) to the values.yaml
of your gitlab-runner deployment does not work, because a mount
into the gitlab-runner pod does not propagate this volume to the different CI stages. Instead, you have to create a PV an PVC to the desired NFS path and link it to the runner as described in the following section:
Setup your Runner Helmchart
The NFS-share is accessible via 10.10.10.10:/volume
I use kustomize to deploy Helmcharts, because this is how we roll in ArgoCD:
kustomization.yaml
|
|
The runner needs a special config for mounting NFS
values.yaml
|
|
Create the PVC and PV in one step.
pvc.yaml
|
|
The caveat is that you have to specify the size of the NFS persistent volume, because .spec.resources.requests.storage
is
mandatory when specifying a persistent volume claim.
Conclusion
Not really trivial, but adding a nfs volume to your Gitlab CI stages should be easy following the guide above.