<p>I am currently using the Kubernetes Executor for Gitlab CI and since:</p>

<p><a href="https://docs.gitlab.com/runner/executors/kubernetes.html" rel="nofollow noreferrer">https://docs.gitlab.com/runner/executors/kubernetes.html</a>:"<em>At this time hostPath, PVC, configMap, and secret volume types are supported".</em></p>

<p>I was wondering if there is a possibility to have a Flex Volume with a Persistent Volume Claim in Kubernetes.</p>

<p>Any type of PV can back a PVC. You need to create the PV by hand and then specify the name in <a href="https://kubernetes.io/docs/api-reference/v1.8/#persistentvolumeclaimspec-v1-core" rel="nofollow noreferrer"><code>.spec.volumeName</code></a> of the PVC (or use <code>.spec.selector</code> with labels). Like so:</p>

<pre><code>kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: task-pv-claim
spec:
  volumeName: task-pv-volume
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi
</code></pre>

<p>As a reference I used this PV (but the type of the PV does not matter):</p>

<pre><code>kind: PersistentVolume
apiVersion: v1
metadata:
  name: task-pv-volume
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/tmp/data"
</code></pre>

<p>(Alternatively, automatic provisioning with your own storageclass is also possible, but I guess this is not your use case.)</p>
