StorageClasses

Persistent storage is provided by 3 Kubernetes StorageClasses:

  1. local (default)
  • Local disk storage for high-performance workloads (e.g. databases managed by CloudNativePG)
  • Retention Policy: Data persists only as long as the underlying node or disk remains healthy and available.
  1. synology-iscsi
  • Persistent volumes provisioned via iSCSI connections to Synology NAS, providing redundancy and centralized management.
  • General-purpose, application configurations, logs.
  • Minimum Size: 1Gi
  • Retention Policy: Volumes follow the lifecycle of the associated PersistentVolumeClaim (PVC). Data is deleted automatically when the PVC is deleted.
  1. synology-iscsi-retain
  • Similar to the default iSCSI class but with a retention policy that preserves data even after PVC deletion.
  • Minimum Size: 1Gi
  • Retention Policy: Persistent volumes remain intact after PVC deletion and require manual cleanup.

Specify the StorageClassName in the PersistentVolumeClaim definition

# storage.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: linkding-data-pvc
spec:
  storageClassName: synology-iscsi-retain
  resources:
    requests:
      storage: 10Gi
  accessModes:
    - ReadWriteOnce
  securityContext:
    fsGroup: 33

Databases

To run PostgreSQL within the cluster, we use CloudNativePG, a Kubernetes operator that automates the management of a highly available PostgreSQL database cluster including self-healing, scale up/down of read-only replicas, resource management, etc.

To deploy a database cluster, define and apply a Cluster object

# cluster-example.yaml
apiVersion: postgresql.cnpg.io/v1 
kind: Cluster 
metadata: 
  name: cluster-example 
spec: 
  instances: 3 
  storage: 
    size: 1Gi
  monitoring:
    enablePodMonitor: true
# Apply cluster yaml file
kubectl apply -f cluster-example.yaml
 
# Use cnpg extention to see cluster status
kubectl cnpg status cluster-example

It is recommended to use the default local-storage StorageClass for maximum performance and rely on automation provided by the CNPG operator to easily back up and restore the database from external storage.


External Storage via Synology NFS

Additionally, the Synology NAS provides Network File System (NFS) shares accessible from outside the Kubernetes cluster:

  • Description: Shared storage provisioned via Synology’s NFS server.
  • Use Cases:
    • External systems needing shared storage access.
    • Persistent storage for non-containerized workloads requiring filesystem-level sharing.
    • Media Library