Files
homelab/k8s/infra/longhorn/longhorn-cnpg-storageclass.yaml
T

42 lines
1.7 KiB
YAML

# StorageClass specifically for CNPG (CloudNativePG) PostgreSQL clusters
# Fixes the "read-only filesystem" issue by mounting with postgres UID/GID
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: longhorn-cnpg
namespace: longhorn-system
annotations:
storageclass.kubernetes.io/is-default-class: "false"
# StorageClass.parameters is immutable. mkfsParams below was added after
# this class already existed, so every sync failed with
# parameters: Invalid value: {...}: field is immutable
# and the Application sat OutOfSync permanently — ArgoCD retrying a change
# the API server can never accept.
#
# Replace=true makes ArgoCD delete and recreate instead of patching. Safe
# for a StorageClass: it is consulted only at provisioning time, so bound
# PVs and their data are untouched. New PVCs briefly fail if one is created
# during the window.
#
# Note what this does NOT do: the nine CNPG volumes already provisioned were
# formatted without mkfsParams and keep that format. Only volumes created
# after this recreate get it. Existing volumes that need to expand still
# need handling separately.
argocd.argoproj.io/sync-options: Replace=true,Force=true
provisioner: driver.longhorn.io
allowVolumeExpansion: true
parameters:
numberOfReplicas: "3"
staleReplicaTimeout: "30"
fromBackup: ""
dataLocality: "best-effort"
fsType: "ext4"
# Mount options to ensure PostgreSQL can write
mkfsParams: "-O ^64bit,^metadata_csum"
mountOptions:
- "noatime"
# Critical: mount with postgres UID/GID (26:26) to avoid permission issues
- "uid=26"
- "gid=26"
reclaimPolicy: Delete
volumeBindingMode: Immediate