<p>emptyDir vs hostPath (and other) volume type usage on a kubernetes deployment</p>

<blockquote>
  <p>As read from official documentation it is stated that when using emptyDir with a POD. 
  <strong>Container crashing does NOT remove a Pod from a node, so the data in an emptyDir volume is safe across Container crashes</strong>.</p>
</blockquote>

<p>So i was questioning <strong>can we somehow force the content of POD survive on upgrade (rollout) using emptyDir volume type along with (node selector/affinity) usage forcing a POD to be pinned to a given node ?</strong>  or hostPath (or other volume type )is what we will need consider at design to make sure data is persisted even during rollout where POD is recreated regardless of node pinning (we have flexibility to pin this app to a large node in cluster)</p>

<p>As you may know, when you upgrade a deployment, it creates a new POD and once running it terminates your previous POD. In such case, the <code>emptyDir</code> is going to be removed (termination of a pod). As you mention, you could use a <code>hostPath</code> in case you have the node selector/affinity and in such scenario the folder would be shared with all the instances of your pod (if replicas > 1). This is actually the answer from @Matt. </p>

<p>The <code>emptyDir</code> is more or less a temporary folder that you use for the life-cycle of your application. You shouldn't store data required when restarting. Somewhere in the documentation of Kubernetes, it is stated that pod could be removed from a node or killed in case of issue (E.g.: Auto-healing).</p>
