<p>I'm having trouble understanding where to store files in a GKE container? I've seen the following documentation of the filesystem layout:</p>

<p><a href="https://cloud.google.com/kubernetes-engine/docs/concepts/node-images#file_system_layout" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/concepts/node-images#file_system_layout</a></p>

<p>But then there are also Dockerfile examples on the web that copy executable files to other paths not listed in the layout, such as <code>/usr</code> or <code>/go</code>. One of these examples is here:</p>

<p><a href="https://github.com/GoogleCloudPlatform/kubernetes-engine-samples/blob/master/hello-app/Dockerfile" rel="nofollow noreferrer">https://github.com/GoogleCloudPlatform/kubernetes-engine-samples/blob/master/hello-app/Dockerfile</a></p>

<p>Another question is: If I have runtime code that needs to download certain configuration information after the container starts, can I write the configuration file to the same directory as my executable? Or do I have to choose <code>/etc</code> or  <code>/tmp</code>.</p>

<p>And finally, the layout documentation states that <code>/home</code> and <code>/var</code> store data for the the lifetime of the boot disk? What does that mean? How does that compare to the lifetime of the pod or the node?</p>

jacob
<p>When you want to store something in a container you can either store something ephemeral or permanent</p>

<ul>
<li><p>To store ephemeral way just choose a path <code>/tmp</code>, <code>/var</code>, <code>/opt</code> etc (this depends on the container set up as well), once the container is restarted the information you would have is the same at the moment the container was created, for instance your binary files and initial config files.</p></li>
<li><p>To store permanent you must have to mount a volume, this is a support for your container where a volume (container path) is linked with a external storage. with this if your container is restarted the volume will be mounted once the container is ready again and you are no gonna lose anything.</p></li>
</ul>

<p>In kubernetes this is called <code>Persistent Volumes</code> and you can leverage this even if you are in another cloud provider, </p>

<p>steps to used</p>

<ul>
<li>Define a path where you would mount the volume in your source code example <code>/myfiles/private</code></li>
<li>Create a storage class in your GKE <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/ssd-pd" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/ssd-pd</a></li>
<li>Create a Persistent Volume Claim in your GKE <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/ssd-pd" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/ssd-pd</a></li>
<li>Relate this storage class with your Kubernetes deployment</li>
</ul>

<p>Example </p>

<p>link the volume with your container</p>

<pre><code>volumeMounts:
  - mountPath: /myfiles/private
    name: any-name-you-want
</code></pre>

<p>relate the persistent volume with your deployment</p>

<pre><code>volumes:
  - name: any-name-you-want
    persistentVolumeClaim:
    claimName: my-claim-name
</code></pre>
