<p>To use storage inside Kubernetes PODs I can use <a href="https://kubernetes.io/docs/concepts/storage/volumes/" rel="noreferrer">volumes</a> and <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="noreferrer">persistent volumes</a>.  While the volumes like <code>emptyDir</code> are ephemeral, I could use <code>hostPath</code> and many other cloud based volume plugins which would provide a persistent solution in volumes itself.</p>
<p>In that case why should I be using Persistent Volume then?</p>

<p>It is very important to understand the main differences between <code>Volumes</code> and <code>PersistentVolumes</code>. Both <code>Volumes</code> and <code>PersistentVolumes</code> are Kubernetes resources which provides an abstraction of a data storage facility.</p>
<ul>
<li><p><code>Volumes</code>: let your pod write to a filesystem that exists as long as the pod exists. They also let you share data between containers in the same pod but data in that volume will be destroyed when the pod is restarted. <code>Volume</code> decouples the storage from the Container. Its lifecycle is coupled to a pod.</p>
</li>
<li><p><code>PersistentVolumes</code>: serves as a long-term storage in your Kubernetes cluster. They exist beyond containers, pods, and nodes. A pod uses a persistent volume claim to to get read and write access to the persistent volume. <code>PersistentVolume</code> decouples the storage from the Pod. Its lifecycle is independent. It enables safe pod restarts and sharing data between pods.</p>
</li>
</ul>
<p>When it comes to <a href="https://kubernetes.io/docs/concepts/storage/volumes/#hostpath" rel="noreferrer">hostPath</a>:</p>
<blockquote>
<p>A <code>hostPath</code> volume mounts a file or directory from the host node's
filesystem into your Pod.</p>
</blockquote>
<p><code>hostPath</code> has its usage scenarios but in general it might not recommended due to several reasons:</p>
<ul>
<li><p>Pods with identical configuration (such as created from a <code>PodTemplate</code>) may behave differently on different nodes due to different files on the nodes</p>
</li>
<li><p>The files or directories created on the underlying hosts are only writable by root. You either need to run your process as root in a privileged Container or modify the file permissions on the host to be able to write to a <code>hostPath</code> volume</p>
</li>
<li><p>You don't always directly control which node your pods will run on, so you're not guaranteed that the pod will actually be scheduled on the node that has the data volume.</p>
</li>
<li><p>If a node goes down you need the pod to be scheduled on other node where your locally provisioned volume will not be available.</p>
</li>
</ul>
<p>The <code>hostPath</code> would be good if for example you would like to use it for log collector running in a <code>DaemonSet</code>.</p>
<p>I recommend the <a href="https://matthewpalmer.net/kubernetes-app-developer/articles/kubernetes-volumes-example-nfs-persistent-volume.html" rel="noreferrer">Kubernetes Volumes Guide</a> as a nice supplement to this topic.</p>
