From c1813fa8b103e9ae3b0fa670bce002e18a1a7267 Mon Sep 17 00:00:00 2001 From: umagnus Date: Tue, 28 Nov 2023 07:11:10 +0000 Subject: [PATCH] add volume cloning doc --- README.md | 1 + deploy/example/cloning/README.md | 66 +++++++++++++++++++ .../cloning/nginx-pod-restored-cloning.yaml | 20 ++++++ .../pvc-smb-cloning.yaml} | 2 +- hack/verify-yamllint.sh | 2 +- 5 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 deploy/example/cloning/README.md create mode 100644 deploy/example/cloning/nginx-pod-restored-cloning.yaml rename deploy/example/{pvc-volume-clone.yaml => cloning/pvc-smb-cloning.yaml} (91%) diff --git a/README.md b/README.md index 7ae796f2d57..ec50213067f 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Please refer to `smb.csi.k8s.io` [driver parameters](./docs/driver-parameters.md - [Set up a Samba Server on a Kubernetes cluster](./deploy/example/smb-provisioner/) - [Basic usage](./deploy/example/e2e_usage.md) - [Windows](./deploy/example/windows) + - [Volume cloning](./deploy/example/cloning) ### Troubleshooting - [CSI driver troubleshooting guide](./docs/csi-debug.md) diff --git a/deploy/example/cloning/README.md b/deploy/example/cloning/README.md new file mode 100644 index 00000000000..9d721de3b6d --- /dev/null +++ b/deploy/example/cloning/README.md @@ -0,0 +1,66 @@ +# Volume Cloning Example + +- supported from v1.11.0 + +## Create a Source PVC + +```console +kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/storageclass-smb.yaml +kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/pvc-smb.yaml +kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/nginx-pod-smb.yaml +``` + +### Check the Source PVC + +```console +$ kubectl exec nginx-smb -- ls /mnt/smb +outfile +``` + +## Create a PVC from an existing PVC +> Make sure application is not writing data to source smb share +```console +kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/cloning/pvc-smb-cloning.yaml +``` +### Check the Creation Status + +```console +$ kubectl describe pvc pvc-smb-cloning +Name: pvc-smb-cloning +Namespace: default +StorageClass: smb +Status: Bound +Volume: pvc-e48e8ace-578f-4031-8e1e-9343e75c2c05 +Labels: +Annotations: pv.kubernetes.io/bind-completed: yes + pv.kubernetes.io/bound-by-controller: yes + volume.beta.kubernetes.io/storage-provisioner: smb.csi.k8s.io + volume.kubernetes.io/storage-provisioner: smb.csi.k8s.io +Finalizers: [kubernetes.io/pvc-protection] +Capacity: 10Gi +Access Modes: RWX +VolumeMode: Filesystem +DataSource: + Kind: PersistentVolumeClaim + Name: pvc-smb +Used By: +Events: + Type Reason Age From Message + ---- ------ ---- ---- ------- + Normal ExternalProvisioning 12s persistentvolume-controller waiting for a volume to be created, either by external provisioner "smb.csi.k8s.io" or manually created by system administrator + Normal Provisioning 12s smb.csi.k8s.io_aks-nodepool1-34988195-vmss000001_7eccface-64d7-4084-9b9c-edebdd7a6855 External provisioner is provisioning volume for claim "default/pvc-smb-cloning" + Normal ProvisioningSucceeded 12s smb.csi.k8s.io_aks-nodepool1-34988195-vmss000001_7eccface-64d7-4084-9b9c-edebdd7a6855 Successfully provisioned volume pvc-e48e8ace-578f-4031-8e1e-9343e75c2c05 +``` + +## Restore the PVC into a Pod + +```console +kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/cloning/nginx-pod-restored-cloning.yaml +``` + +### Check Sample Data + +```console +$ kubectl exec nginx-smb-restored-cloning -- ls /mnt/smb +outfile +``` \ No newline at end of file diff --git a/deploy/example/cloning/nginx-pod-restored-cloning.yaml b/deploy/example/cloning/nginx-pod-restored-cloning.yaml new file mode 100644 index 00000000000..2b9ad89376d --- /dev/null +++ b/deploy/example/cloning/nginx-pod-restored-cloning.yaml @@ -0,0 +1,20 @@ +--- +kind: Pod +apiVersion: v1 +metadata: + name: nginx-smb-restored-cloning +spec: + containers: + - image: mcr.microsoft.com/oss/nginx/nginx:1.17.3-alpine + name: nginx-smb-restored-cloning + command: + - "/bin/sh" + - "-c" + - while true; do echo $(date) >> /mnt/smb/outfile; sleep 1; done + volumeMounts: + - name: smb01 + mountPath: "/mnt/smb" + volumes: + - name: smb01 + persistentVolumeClaim: + claimName: pvc-smb-cloning diff --git a/deploy/example/pvc-volume-clone.yaml b/deploy/example/cloning/pvc-smb-cloning.yaml similarity index 91% rename from deploy/example/pvc-volume-clone.yaml rename to deploy/example/cloning/pvc-smb-cloning.yaml index a9b85a256be..266d878fbdb 100644 --- a/deploy/example/pvc-volume-clone.yaml +++ b/deploy/example/cloning/pvc-smb-cloning.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: pvc-smb-clone + name: pvc-smb-cloning namespace: default spec: accessModes: diff --git a/hack/verify-yamllint.sh b/hack/verify-yamllint.sh index 324c7619e6c..69cbaaa6358 100755 --- a/hack/verify-yamllint.sh +++ b/hack/verify-yamllint.sh @@ -20,7 +20,7 @@ fi LOG=/tmp/yamllint.log -for path in "deploy/*.yaml" "deploy/example/*.yaml" "deploy/example/windows/*.yaml" "deploy/example/smb-provisioner/*.yaml" "deploy/example/metrics/*.yaml" +for path in "deploy/*.yaml" "deploy/example/*.yaml" "deploy/example/windows/*.yaml" "deploy/example/smb-provisioner/*.yaml" "deploy/example/metrics/*.yaml" "deploy/example/cloning/*.yaml" do echo "checking yamllint under path: $path ..." yamllint -f parsable $path | grep -v "line too long" > $LOG