<p>I have an application which accesses a couple of files from a directory. I went through kubernetes volumes and persistent volumes and volume claims. this is a multi-node kubernetes cluster. do we have any direct solution which can be used which does not need any external storage like a nfs server etc?</p>

<p>I have a VM server from where i execute my kubernetes commands. I am new to kubernetes so please help me with this.</p>

<p>Also i was looking at local persistent volume. is there a link which i can go through for an example. I am looking at local <a href="https://kubernetes.io/docs/concepts/storage/volumes/#local" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/storage/volumes/#local</a></p>

<p>But the example does not explain what below are under nodeAffinity:</p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: example-pv
spec:
  capacity:
    storage: 100Gi
  # volumeMode field requires BlockVolume Alpha feature gate to be enabled.
  volumeMode: Filesystem
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Delete
  storageClassName: local-storage
  local:
    path: /mnt/disks/ssd1
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - example-node
</code></pre>

<p>This depends on your use case, if the files you want to share across the cluster are more than a few megabytes in size, you'll need some kind of storage operator. Local storage is probably not what you're looking for.</p>
<hr />
<h2>For small files (configs, keys, init scripts)</h2>
<p>If the files are small, such as configuration files or ssh keys or similar you can use a kubernetes configmap (or secret). This will allow you to setup a few files or directories with a few files. <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/" rel="nofollow noreferrer">Checkout the documentation</a></p>
<hr />
<h2>For large files (shared data, graphics, binaries)</h2>
<p>If however you want to share a few hundred megabytes or gigabytes of files, you need a storage provider with your cluster.</p>
<p>If you are using a cloud provider, such as Google, AWS or Azure, this should be straightforward, you need to create a persistent disk with your cloud provider and copy your required data onto the disk. Once that's done, simply follow the guide for the relevant cloud providers:</p>
<ul>
<li>Google Cloud - <a href="https://kubernetes.io/docs/concepts/storage/volumes/#gcepersistentdisk" rel="nofollow noreferrer">GCE Persistent Disk</a></li>
<li><strike>AWS - <a href="https://kubernetes.io/docs/concepts/storage/volumes/#awselasticblockstore" rel="nofollow noreferrer">Elastic Block Storage</a></strike></li>
<li><strike>Azure - <a href="https://kubernetes.io/docs/concepts/storage/volumes/#azuredisk" rel="nofollow noreferrer">Azure Disk</a></strike></li>
</ul>
<p>(@justcompile pointed out that AWS doesn't support multiple read-only mounts to instances, I was unable to find similar information for Azure)</p>
<p>If however, you're running your own kubernetes cluster on &quot;baremetal&quot;, you'll have to setup either an NFS server, a <a href="https://ceph.com/" rel="nofollow noreferrer">Ceph cluster</a> and probably use something like <a href="https://github.com/rook/rook" rel="nofollow noreferrer">rook</a> on top.</p>
