<p>What is the best way to preload large files into a local PersistentVolume SSD before it gets used by Kubernetes pods?</p>

<p>The goal is to have multiple pods (could be multiple instances of the same pod, or different), share the same local SSD drive in a read-only mode. The drive would need to be initialized somehow with a large dataset.</p>

<p>Google <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/local-ssd" rel="nofollow noreferrer">Local SSD docs</a> describes the <code>Running the local volume static provisioner</code>, but that approach only creates a PersistedVolume, but does not initialize it.</p>

<p>Basically, you can add an <code>init</code> container to your pod that initializes the SSD: add data, etc.</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: "test-ssd"
spec:
  initContainers:
  - name: "init"
    image: "ubuntu:14.04"
    command: ["/bin/init_my_ssd.ssh"]
    volumeMounts:
    - mountPath: "/test-ssd/"
      name: "test-ssd:
  containers:
  - name: "shell"
    image: "ubuntu:14.04"
    command: ["/bin/sh", "-c"]
    args: ["echo 'hello world' &gt; /test-ssd/test.txt &amp;&amp; sleep 1 &amp;&amp; cat /test-ssd/test.txt"]
    volumeMounts:
    - mountPath: "/test-ssd/"
      name: "test-ssd"
  volumes:
  - name: "test-ssd"
    hostPath:
      path: "/mnt/disks/ssd0"
  nodeSelector:
    cloud.google.com/gke-local-ssd: "true"
</code></pre>
