<p>Right from start: very beginner in kubernetes here.</p>
<p>I (think to) know how I can create a volume for my <code>StatefulSet</code> for persistence. For that, I have</p>
<pre><code>          volumeMounts:
            - name: db
              mountPath: /var/lib/mydb
</code></pre>
<p>and</p>
<pre><code>    - metadata:
      name: db
      labels:
        app: myapp
      spec:
        accessModes: [ &quot;ReadWriteOnce&quot; ]
        resources:
          requests:
            storage: 50Gi 
</code></pre>
<p>I assume this would give my pods <strong>each</strong> (?) 50GB of space to persist their stuff.</p>
<p>This helps me test my app when the DB is empty and start from scratch. It would, I guess, be able to reuse the DB if pods were shutdown and restarted - that's how I understand this persistence.</p>
<p>However, I would like to be able to test with a DB with history also, with potentially several GB size already. This means, every pod would mount an existing DB <em>and go from there</em>. Therefore every pod needs to access the file <strong>but also needs to mount it independently and exclusively</strong>. I can't just mount an existing volume and have it shared between the pods.</p>
<p>The DB should be an on-disk key-value store like <code>leveldb</code>.</p>
<p>This would allow to test the app from different existing states of the DB.</p>
<p>Is this possible?</p>

transient_loop
<p>Before starting playing with StatefulSets I advice you to read doc - <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">statefulset-official-doc</a>.  Take a look also on <a href="https://kubernetes.io/docs/concepts/storage/dynamic-provisioning/" rel="nofollow noreferrer">dynamics-provisioning</a>.  Similary as @SYN said:</p>
<p><strong>1.</strong> Create  create PVCs - specify storage class and size there, even before creating  StatefulSet.</p>
<p><strong>2.</strong> Create a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/job/" rel="nofollow noreferrer">Job</a> /Pod which would mount your volume and either automatically set it up and extract your data the way you want them. Mount it to the directory, which is used by your DB to store the data. When the volumes are ready, shut down your init Pod.</p>
<p><strong>3.</strong>  Create your StatefulSet. Instead of creating new PVCs, reuse ones you've prepared.</p>
