在相应 StorageClass 中使用 Retail 回收策略时,删除后根本不会创建 PVC

PVCs not created at all after deletion, when using Retail reclaim policy in corresponding StorageClass

我正在使用 ECK operator 创建一个 Elasticsearch 实例。

该实例使用 StorageClass 作为其回收策略 Retain(而不是 Delete)。

这是我的 PVCs before 删除 Elasticsearch 实例

▶ k get pvc
NAME                                                   STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS              AGE
elasticsearch-data--es-multirolenodes1-0   Bound    pvc-ba157213-67cf-4b81-8fe2-6211b771e62c   20Gi       RWO               balanced-retain-csi   8m15s
elasticsearch-data--es-multirolenodes1-1   Bound    pvc-e77dbb00-7cad-419f-953e-f3398e3860f4   20Gi       RWO               balanced-retain-csi   7m11s
elasticsearch-data--es-multirolenodes1-2   Bound    pvc-b258821b-0d93-4ea3-8bf1-db590b93adfd   20Gi       RWO               balanced-retain-csi   6m5s

我删除并重新创建了 Elasticsearch 实例,希望由于 Retain 政策,新的 pods(即他们的 PVC 将绑定到现有的 PVs(并且数据不会丢失)

但是现在我的 nodeSet 中的 pods 都处于挂起状态并出现此错误

Events:
  Type     Reason             Age                  From                Message
  ----     ------             ----                 ----                -------
  Warning  FailedScheduling   2m37s                default-scheduler   persistentvolumeclaim "elasticsearch-data--es-multirolenodes1-0" is being deleted
  Normal   NotTriggerScaleUp  2m32s                cluster-autoscaler  pod didn't trigger scale-up: 2 persistentvolumeclaim "elasticsearch-data--es-multirolenodes1-0" not found
  Warning  FailedScheduling   12s (x7 over 2m37s)  default-scheduler   persistentvolumeclaim "elasticsearch-data--es-multirolenodes1-0" not found

为什么会这样?

编辑:这里是对应的PVs

▶ k get pv 
pvc-b258821b-0d93-4ea3-8bf1-db590b93adfd   20Gi       RWO            Retain           Released   elastic/elasticsearch-data--es-multirolenodes1-2          balanced-retain-csi            20m
pvc-ba157213-67cf-4b81-8fe2-6211b771e62c   20Gi       RWO            Retain           Released   elastic/elasticsearch-data--es-multirolenodes1-0          balanced-retain-csi            22m
pvc-e77dbb00-7cad-419f-953e-f3398e3860f4   20Gi       RWO            Retain           Released   elastic/elasticsearch-data--es-multirolenodes1-1          balanced-retain-csi            21m

现在当然没有了PVC

▶ k get pvc                       
No resources found in elastic namespace.

考虑中的 StorageClass 正在使用 GCP 永久磁盘的 csi 驱动程序,fwiw

with the hope that due to the Retain policy, the new pods (i.e. their PVCs would bind to the existing PVs (and data wouldn't get lost)

documentation 中明确写明这不是发生的事情。删除 PVC 后,PV 可用于另一个 PVC。

the PersistentVolume still exists and the volume is considered "released". But it is not yet available for another claim because the previous claimant's data remains on the volume.