|
| 1 | +# Volume Cloning Example |
| 2 | + |
| 3 | +- supported from v4.3.0 |
| 4 | + |
| 5 | +## Create a Source PVC |
| 6 | + |
| 7 | +```console |
| 8 | +kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/deploy/example/storageclass-nfs.yaml |
| 9 | +kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/deploy/example/pvc-nfs-csi-dynamic.yaml |
| 10 | +kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/deploy/example/nginx-pod-nfs.yaml |
| 11 | +``` |
| 12 | + |
| 13 | +### Check the Source PVC |
| 14 | + |
| 15 | +```console |
| 16 | +$ kubectl exec nginx-nfs -- ls /mnt/nfs |
| 17 | +outfile |
| 18 | +``` |
| 19 | + |
| 20 | +## Create a PVC from an existing PVC |
| 21 | +> Make sure application is not writing data to source nfs share |
| 22 | +```console |
| 23 | +kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/deploy/example/cloning/pvc-nfs-cloning.yaml |
| 24 | +``` |
| 25 | +### Check the Creation Status |
| 26 | + |
| 27 | +```console |
| 28 | +$ kubectl describe pvc pvc-nfs-cloning |
| 29 | +Name: pvc-nfs-cloning |
| 30 | +Namespace: default |
| 31 | +StorageClass: nfs-csi |
| 32 | +Status: Bound |
| 33 | +Volume: pvc-5a00da0e-9afe-40f7-9f52-edabcf28df63 |
| 34 | +Labels: <none> |
| 35 | +Annotations: kubectl.kubernetes.io/last-applied-configuration: |
| 36 | + {"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{},"name":"pvc-nfs-cloning","namespace":"default"},"spec":{"ac... |
| 37 | + pv.kubernetes.io/bind-completed: yes |
| 38 | + pv.kubernetes.io/bound-by-controller: yes |
| 39 | + volume.beta.kubernetes.io/storage-provisioner: nfs.csi.k8s.io |
| 40 | + volume.kubernetes.io/storage-provisioner: nfs.csi.k8s.io |
| 41 | +Finalizers: [kubernetes.io/pvc-protection] |
| 42 | +Capacity: 10Gi |
| 43 | +Access Modes: RWX |
| 44 | +VolumeMode: Filesystem |
| 45 | +Mounted By: <none> |
| 46 | +Events: |
| 47 | + Type Reason Age From Message |
| 48 | + ---- ------ ---- ---- ------- |
| 49 | + Normal ExternalProvisioning 5s persistentvolume-controller waiting for a volume to be created, either by external provisioner "nfs.csi.k8s.io" or manually created by system administrator |
| 50 | + Normal Provisioning 5s nfs.csi.k8s.io_aks-nodepool1-34988195-vmss000000_534f1e86-3a71-4ca4-9b83-803c05a44d65 External provisioner is provisioning volume for claim "default/pvc-nfs-cloning" |
| 51 | + Normal ProvisioningSucceeded 5s nfs.csi.k8s.io_aks-nodepool1-34988195-vmss000000_534f1e86-3a71-4ca4-9b83-803c05a44d65 Successfully provisioned volume pvc-5a00da0e-9afe-40f7-9f52-edabcf28df63 |
| 52 | +``` |
| 53 | + |
| 54 | +## Restore the PVC into a Pod |
| 55 | + |
| 56 | +```console |
| 57 | +kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/deploy/example/cloning/nginx-pod-restored-cloning.yaml |
| 58 | +``` |
| 59 | + |
| 60 | +### Check Sample Data |
| 61 | + |
| 62 | +```console |
| 63 | +$ kubectl exec nginx-nfs-restored-cloning -- ls /mnt/nfs |
| 64 | +outfile |
| 65 | +``` |
0 commit comments