From 339b10eb03bc37affcf5cbf7f855eca4c49b0db6 Mon Sep 17 00:00:00 2001 From: peng9808 Date: Mon, 15 Jul 2024 09:52:18 +0800 Subject: [PATCH] make data safer by default.in case user delete pvc by accident , and data lost happens Signed-off-by: peng9808 --- helm/operator/templates/hwameistorcluster.yaml | 2 +- helm/operator/values.yaml | 2 ++ pkg/install/storageclass/storageclass.go | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/helm/operator/templates/hwameistorcluster.yaml b/helm/operator/templates/hwameistorcluster.yaml index 57f05860..9f1b2a4b 100644 --- a/helm/operator/templates/hwameistorcluster.yaml +++ b/helm/operator/templates/hwameistorcluster.yaml @@ -255,7 +255,7 @@ spec: chartVersion: "v0.4.1" storageClass: allowVolumeExpansion: true - reclaimPolicy: "Delete" + reclaimPolicy: {{ $.Values.storageClassReclaimPolicy }} fsType: "xfs" dataLoadManager: diff --git a/helm/operator/values.yaml b/helm/operator/values.yaml index 1d3978a6..70b2e0d3 100644 --- a/helm/operator/values.yaml +++ b/helm/operator/values.yaml @@ -183,6 +183,8 @@ dataLoadInit: imageRepository: hwameistor/dataload-init tag: v0.0.1 + +#storageClassReclaimPolicy: Retain > Delete #datasetDefaultPoolClass: NVMe > SSD > HDD # diskReserve example diff --git a/pkg/install/storageclass/storageclass.go b/pkg/install/storageclass/storageclass.go index c97933f4..9db2b9a2 100644 --- a/pkg/install/storageclass/storageclass.go +++ b/pkg/install/storageclass/storageclass.go @@ -34,7 +34,7 @@ func NewMaintainer(cli client.Client, clusterInstance *hwameistoroperatorv1alpha var volumeBindingWaitForFirstConsumer = storagev1.VolumeBindingWaitForFirstConsumer var defaultAllowVolumeExpansionBooleanValue = true -var defaultReclaimPolicy = corev1.PersistentVolumeReclaimDelete +var defaultReclaimPolicy = corev1.PersistentVolumeReclaimRetain var defaultDiskType = "HDD" var defaultFSType = "xfs"