Root Cause
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 寫入的資料才會真正持久化。