Storage

Choose The Right Storage Class

Prevent Data Loss

Helm

To prevent accidental data loss for production helm deployments we strongly recommend to add the following annotation to all PVCs:

metadata:
  annotations:
    helm.sh/resource-policy: keep

This will prevent uninstallation of the PVCs and the underlaying PVs. The PVCs will be reused by a re-deployment if possible.

Retained PVs

For additional robustness of production deployments, you can ask our service desk to change the reclaim policy of longhorn PVs to Retain. This way the PV will never be deleted. A redeployment will still create a new PV but you can attache the old PV using its name. We recommend to record each PV size and volumeName somewhere safe:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: old-data-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi  # Ensure this matches or is smaller than the size of the PV.
  storageClassName: ""  # Use an empty string to bind to a specific PV with no storage class.
  volumeName:  # Directly specify the PV name here.

This is recommended for longhorn storage.


Page URL: https://www.isg.inf.ethz.ch/bin/view/Main/HelpKubernetesBestPracticesStorage
2025-10-07
© 2025 Eidgenössische Technische Hochschule Zürich