You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在IBM Cloud Kubernetes中将Bronze保留型PV迁移至ibmc-file-retain-gold存储类

Got it, let's walk through how to migrate your Bronze PV (with a Retain policy) to the ibmc-file-retain-gold storage class while keeping all your data intact. I've broken this down into clear, safe steps to avoid data loss:

Step 1: Stop all workloads using the target PV

First, you need to halt any pods writing to the PV to prevent data corruption. Let's find which pods are using the PVC bound to your PV:

kubectl get pods --all-namespaces -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.volumes[*].persistentVolumeClaim.claimName}{"\n"}{end}' | grep <your-pvc-name>

Once you have the pod names, delete them (or scale down their deployment if they're managed by one):

# Delete individual pods
kubectl delete pod <pod-name> -n <namespace>

# Or scale down a deployment to stop all replicas
kubectl scale deployment <deployment-name> -n <namespace> --replicas=0
Step 2: Delete the bound PVC

Since your PV uses the Retain policy, deleting the PVC won't touch the underlying storage volume—instead, the PV will shift to a Released state. Run:

kubectl delete pvc <your-pvc-name> -n <namespace>

Verify the PV's status to confirm it's released:

kubectl get pv <your-pv-name>

You should see STATUS: Released in the output.

Step 3: Grab the underlying IBM Cloud storage volume ID

Next, we need the unique ID of the actual File Storage volume in IBM Cloud that's backing your PV. Describe the PV to find this detail:

kubectl describe pv <your-pv-name>

Look for annotations like ibm.io/volume-id or fields under PersistentVolumeSource > IBMCloudFile that show the volume GUID. Note this value down (we'll call it <volume-guid> for later).

Step 4: Delete the old Bronze PV

Now you can safely delete the old PV—remember, the underlying storage volume is still intact thanks to the Retain policy:

kubectl delete pv <your-pv-name>
Step 5: Create a new Gold-class PVC linked to your existing volume

Create a YAML file (e.g., gold-pvc.yaml) that defines a PVC using the ibmc-file-retain-gold storage class and references your existing volume. Make sure the storage size and access mode match your original PV:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: <new-gold-pvc-name>
  namespace: <your-namespace>
spec:
  storageClassName: ibmc-file-retain-gold
  accessModes:
    - ReadWriteOnce  # Match the access mode of your original PV
  resources:
    requests:
      storage: <original-volume-size>  # Must be exactly the same as your old volume
  volumeName: <volume-guid>  # Use the volume ID you noted earlier

Apply this PVC to your cluster:

kubectl apply -f gold-pvc.yaml
Step 6: Verify and restart your workloads

Check that the new PVC is bound to a fresh Gold-class PV:

kubectl get pvc <new-gold-pvc-name> -n <your-namespace>
kubectl get pv

You should see the new PV with STATUS: Bound and STORAGECLASS: ibmc-file-retain-gold.

Now restart your pods or scale up the deployment to use the new PVC:

# Scale up a deployment
kubectl scale deployment <deployment-name> -n <namespace> --replicas=1

# Or create a new pod pointing to the new PVC
Key Notes
  • The storage size in the new PVC must exactly match your original volume's size—you can't resize during this migration unless you first resize the underlying IBM Cloud File Storage volume.
  • Double-check that the access mode (e.g., ReadWriteOnce, ReadWriteMany) matches your original PV to avoid compatibility issues.
  • If the PVC fails to bind, confirm the ibmc-file-retain-gold storage class exists in your cluster:
    kubectl get storageclasses
    

内容的提问来源于stack exchange,提问作者icordoba

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 07:05:06