4

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.

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.

James Teague II
  • 279
  • 5
  • 13
  • 2
    Sounds like a client-server style DBM like postgres might be more appropriate to your needs. – Shawn May 02 '19 at 05:47
  • 1
    I totally agree with you. That is probably the proper way to do it. The only issue is those apps in the image don't support switching the type of the backend database. I may end up being hosed here but for the time being I and going to try to get a local persistent volume up on a specific node. – James Teague II May 03 '19 at 00:21

1 Answers1

4

It seems you should use Local Persistent Volumes GA.

As per documentation:

A local volume represents a mounted local storage device such as a disk, partition or directory.

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.

However:

At GA, Local Persistent Volumes do not support dynamic volume provisioning.

More information you can find here, and here.

As one example:

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

With Local Persistent Volumes, the Kubernetes scheduler ensures that a pod using a Local Persistent Volume is always scheduled to the same node

Community
  • 1
  • 1
Mark
  • 3,644
  • 6
  • 23
  • 2
    What does "GA" mean? The way you quote it, it sounds like company name. – bluenote10 Apr 06 '20 at 16:01
  • 1
    As stated in the provided links above [generally available, stable](https://kubernetes.io/docs/reference/using-api/deprecation-policy/#deprecating-parts-of-the-api) – Mark Apr 08 '20 at 16:58
  • 1
    Thanks! Note however, that both provided links do not contain the words "generally available", only GA everywhere, which is why I asked. – bluenote10 Apr 08 '20 at 20:25
  • It sounds like if the node with the storage goes down, containers that use the storage won’t be able to run. OP has 2 nodes, and probably wants a pod to be able to run on either of them. – majorgear Feb 18 '23 at 17:14