Hi Everyone,
I’m a newbie here and trying to understand all the ins and outs of the Longhorn. But still no luck.
My app doesn’t have built-in data replication and therefore StatefulSet is not an option for me. I want to achieve a simple HA: an app with 2-3 replicas deployed on different nodes but using the same persistent volume (in another words - an equivalent of a shared NFS RWX PV but with data redundancy). For example: an “Adguard Server” that should automatically sync its configuration between the nodes by means of the shared/replicated storage. There’s a similar thread which suggests to use NFS. But my idea was to get rid of the seemingly redundant layer of NFS.
So, how to achieve that with Longhorn?
Assume the following flow: Deployment (3 replicas) → PVC → Longhorn StorageClass (dataLocality: strict-local). By definition a PVC is shared among all replicas in the deployment. However, only a single Hostpath RWO PV can exist per each node. Therefore with standard Hostpath RWO PV all my replicas on different nodes (except for the first one) should fail to mount PV. But what would happen with Longhorn-backed PV? Would it create replicas of the PV on each node by default? (i.e. will my application data be replicated among deplyment replicas?) Do I need to create Longhorn StorageClass with numberOfReplicas 1
or 3 replicas to have a single PV instance per node?
Q2. I want something that will atomatically replicate PV with pod expansion to new nodes. and automatically delete PVs on pod reduction. There’s an eviction policy for replicas that one can setup in the UI. But how to configure it in the yaml definition per PVC or per-StorageClass?