How to confirm data security after adjust Kubernetes PV’s reclaimPolicy and delete the pvc bound with such PV

  Kiến thức lập trình

I have encountered such problem. Clients want to migrate data from namespace A to namespace B. The data is stored in Ceph and managed by ceph csi. The default reclaim policy is delete. So If I want to complete this, I need to change PV’s reclaim policy from delete to retain and then delete pvc. After this, I can generate new pvc binding with the PV by volumeName field. It works if I operate manually. However, the scale is not that small. I want to make this process automatically. However, it causes data loss.

The pseudo-code is as follow:

func Migrate() {    
    pv := getPV()
    oldPVC := getOldPVC(pvcName, namespaceA)
    pv.ReclaimPolicy = "Retain"
    pvConroller.Update(pv)
    for {
        curPV := pvController.GetPV(pvName)
        if curPV.ReclaimPolicy == "Retain" {
            break
        }
        // retry get for loop
    }
    pvcController.Delete(oldPVC)
    ...
    // genetate new pvc and bind
}

Is there any way to confirm deleting pvc operation after pv has been updated by controller rather than just recording in ETCD

New contributor

Yuchen Song is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT