根本原因
Zeabur 在建立 volume 时,将 PVC 的 mountPath 默认设为 /insforge-storage(根目录),但 insforge 应用程序实际上是将文件写入 /app/backend/insforge-storage。
两个路径不一致,导致:
- PVC 挂在
/insforge-storage→ 持久化,但 app 不写这里 - App 写入
/app/backend/insforge-storage→ 没有 PVC 保护,只是 container 内的临时空间
每次 pod 重启,container filesystem 重置,/app/backend/insforge-storage 的数据就消失。
解决方法
前置确认
确认目前 pod 内 /app/backend/insforge-storage 是否有需要保留的数据:
kubectl exec -n <namespace> <pod-name> -- ls -la /app/backend/insforge-storage/
Step 1:若有数据,先备份至 PVC
在改 mountPath 之前,趁 pod 还活着,把数据复制进目前挂载的 PVC(/insforge-storage):
kubectl exec -n <namespace> <pod-name> -- cp -r /app/backend/insforge-storage/. /insforge-storage/
这样数据就先安全存在 PVC 里,之后改完 mountPath 就能在正确位置取回。
Step 2:修改 Deployment 的 volumeMount mountPath
找到对应 Deployment(service-698431469758a4530cd3b774),将 volumeMounts 的路径从:
mountPath: /insforge-storage
改为:
mountPath: /app/backend/insforge-storage
Step 3:重新 rollout
套用变更后,让 pod 重启,新 pod 就会把 PVC 直接挂在 /app/backend/insforge-storage,app 写入的数据才会真正持久化。