<p>I have a multi-node (2) Kubernetes cluster running on bare metal. I understand that 1. hostPath is bad for production and 2. hostPath Persistent Volumes are not supported for multi-node setups. Is there a way that I can safely run apps that are backed by a SQLite database? Over NFS the database locks a lot and really hurts the performance of the apps.</p>

<p>I would probably place the SQLite databases for each app on the hostPath volume and everything would run smoothly again. But I was wondering if there are some workarounds to achieve this, even if I have to restrict apps to a specific node.</p>

<p>It seems you should use <strong>Local Persistent Volumes GA</strong>.</p>
<p>As per documentation:</p>
<blockquote>
<p>A local volume represents a mounted local storage device such as a disk, partition or directory.</p>
<p>Compared to hostPath volumes, local volumes can be used in a durable and portable manner without manually scheduling Pods to nodes, as the system is aware of the volume’s node constraints by looking at the node affinity on the PersistentVolume.</p>
</blockquote>
<p>However:</p>
<blockquote>
<p>At GA, Local Persistent Volumes do not support dynamic volume provisioning.</p>
</blockquote>
<p>More information you can find <a href="https://kubernetes.io/blog/2019/04/04/kubernetes-1.14-local-persistent-volumes-ga/" rel="nofollow noreferrer">here</a>, and <a href="https://kubernetes.io/docs/concepts/storage/volumes/#local" rel="nofollow noreferrer">here</a>.</p>
<p>As one example:</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>
<blockquote>
<p>With Local Persistent Volumes, the Kubernetes scheduler ensures that a pod using a Local Persistent Volume is always scheduled to the same node</p>
</blockquote>
