From b86e2a63cc6e62546ba449c276c64957286e521b Mon Sep 17 00:00:00 2001 From: red Date: Sat, 12 Jul 2025 10:14:37 -0400 Subject: [PATCH] rework postgres storage to single-replica best-effort --- manifests/darkdork.dev/storageclass.yaml | 24 ++++--------------- manifests/postgres/pvc.yaml | 30 ++++++++++++++++++++++++ manifests/postgres/statefulset.yaml | 9 +++++-- 3 files changed, 42 insertions(+), 21 deletions(-) diff --git a/manifests/darkdork.dev/storageclass.yaml b/manifests/darkdork.dev/storageclass.yaml index 53221a8..73071ce 100644 --- a/manifests/darkdork.dev/storageclass.yaml +++ b/manifests/darkdork.dev/storageclass.yaml @@ -2,27 +2,13 @@ kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: - name: longhorn-ssd + name: longhorn-single-replica-best-effort namespace: darkdork-dev provisioner: driver.longhorn.io allowVolumeExpansion: true parameters: - numberOfReplicas: "3" - staleReplicaTimeout: "2880" # 48 hours in minutes + numberOfReplicas: "1" + staleReplicaTimeout: "30" + fsType: "ext4" fromBackup: "" - fsType: "xfs" -# backupTargetName: "default" -# mkfsParams: "-I 256 -b 4096 -O ^metadata_csum,^64bit" -# diskSelector: "ssd,fast" -# nodeSelector: "storage,fast" -# recurringJobSelector: '[ -# { -# "name":"snap", -# "isGroup":true, -# }, -# { -# "name":"backup", -# "isGroup":false, -# } -# ]' ---- + data-locality: "best-effort" diff --git a/manifests/postgres/pvc.yaml b/manifests/postgres/pvc.yaml index 9e4024d..05a92cc 100644 --- a/manifests/postgres/pvc.yaml +++ b/manifests/postgres/pvc.yaml @@ -10,6 +10,36 @@ spec: volumeName: pvc-43c3a05b-5556-4d7c-83e3-ee6436f1a48e accessModes: ["ReadWriteOnce"] storageClassName: longhorn-ssd + resources: + requests: + storage: 10Gi + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: postgres-local-pvc + namespace: darkdork-dev + labels: + app: postgres +spec: + accessModes: ["ReadWriteOnce"] + storageClassName: longhorn-single-replica-best-effort + resources: + requests: + storage: 15Gi + +--- +apiVersion: v1 +kind: PersistenVolumeClaim +metadata: + name: postgres-local-path-test-pvc + namespace: darkdork-dev + labels: + app: postgres +spec: + accessModes: ["ReadWriteOnce"] + storageClassName: local-path resources: requests: storage: 10Gi \ No newline at end of file diff --git a/manifests/postgres/statefulset.yaml b/manifests/postgres/statefulset.yaml index 4031d5b..8fe7c2e 100644 --- a/manifests/postgres/statefulset.yaml +++ b/manifests/postgres/statefulset.yaml @@ -50,7 +50,7 @@ spec: - name: PGDATA value: /var/lib/postgresql/data/pgdata volumeMounts: - - name: postgres-storage + - name: postgres-local mountPath: /var/lib/postgresql/data subPath: pgdata # Using subPath to avoid permission issues - name: dshm @@ -60,6 +60,8 @@ spec: - name: postgres-config-volume mountPath: /etc/postgresql/postgresql.conf subPath: postgresql.conf + - name: postgres-local + mountPath: /mnt command: - docker-entrypoint.sh - -c @@ -114,4 +116,7 @@ spec: name: postgres-config - name: postgres-storage persistentVolumeClaim: - claimName: postgres-pvc \ No newline at end of file + claimName: postgres-pvc + - name: postgres-local + persistentVolumeClaim: + claimName: postgres-local-pvc \ No newline at end of file