For cnpg postgres cluster, they already did replication, so from the idea in this blog:
I tried multiple ways to create a longhorn sc that :
- 1 replica only, that means one copy only, no need replicate
- need to create with the postgres pod, local, since cnpg created on 3 nodes, means need pv at 3 nodes as well.
But failed with all pv created on same node. here is my yaml:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: longhorn-storageclass-1r
provisioner: driver.longhorn.io
parameters:
numberOfReplicas: "1" # Set to 1 replica
staleReplicaTimeout: "30"
fromBackup: "" # (Optional) Leave blank if not restoring from a backup
allowVolumeExpansion: true
reclaimPolicy: Delete
volumeBindingMode: Immediate