From f67018f56dce43a85ab23abd38e13b11b56cdebc Mon Sep 17 00:00:00 2001 From: umagnus Date: Fri, 24 Nov 2023 07:44:09 +0000 Subject: [PATCH] add volume cloning doc --- README.md | 1 + deploy/example/cloning/README.md | 66 +++++++++++++++++++ .../cloning/nginx-pod-restored-cloning.yaml | 21 ++++++ .../pvc-blob-csi-cloning.yaml} | 2 +- hack/verify-yamllint.sh | 2 +- 5 files changed, 90 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-blob-csi-clone.yaml => cloning/pvc-blob-csi-cloning.yaml} (91%) diff --git a/README.md b/README.md index 4c798a9c6..1dd15913b 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ This option does not depend on cloud provider config file, supports cross subscr - [Basic usage](./deploy/example/e2e_usage.md) - [NFSv3](./deploy/example/nfs) - [fsGroupPolicy](./deploy/example/fsgroup) + - [Volume cloning](./deploy/example/cloning) - [Workload identity](./docs/workload-identity.md) ### Troubleshooting diff --git a/deploy/example/cloning/README.md b/deploy/example/cloning/README.md new file mode 100644 index 000000000..c81e11482 --- /dev/null +++ b/deploy/example/cloning/README.md @@ -0,0 +1,66 @@ +# Volume Cloning Example +## Feature Status: Beta + +- supported from v1.23.2 + +## Create a Source PVC + +```console +kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/blob-csi-driver/master/deploy/example/storageclass-blobfuse2.yaml +kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/blob-csi-driver/master/deploy/example/pvc-blob-csi.yaml +kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/blob-csi-driver/master/deploy/example/nginx-pod-blob.yaml +``` + +### Check the Source PVC + +```console +$ kubectl exec nginx-blob -- ls /mnt/blob +outfile +``` + +## Create a PVC from an existing PVC +> Make sure application is not writing data to source blob container +```console +kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/blob-csi-driver/master/deploy/example/cloning/pvc-blob-cloning.yaml +``` +### Check the Creation Status + +```console +$ kubectl describe pvc pvc-blob-cloning +Name: pvc-blob-cloning +Namespace: default +StorageClass: blob-fuse +Status: Bound +Volume: pvc-6db5af93-3b32-4c24-a68e-b727d7801fd5 +Labels: +Annotations: kubectl.kubernetes.io/last-applied-configuration: + {"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{},"name":"pvc-blob-cloning","namespace":"default"},"spec":{"a... + pv.kubernetes.io/bind-completed: yes + pv.kubernetes.io/bound-by-controller: yes + volume.beta.kubernetes.io/storage-provisioner: blob.csi.azure.com + volume.kubernetes.io/storage-provisioner: blob.csi.azure.com +Finalizers: [kubernetes.io/pvc-protection] +Capacity: 100Gi +Access Modes: RWX +VolumeMode: Filesystem +Mounted By: +Events: + Type Reason Age From Message + ---- ------ ---- ---- ------- + Normal Provisioning 16s blob.csi.azure.com_aks-nodepool1-34988195-vmss000002_8ecdf8ad-b636-4ca5-81ee-0f1a49337168 External provisioner is provisioning volume for claim "default/pvc-blob-cloning" + Normal ExternalProvisioning 14s (x3 over 16s) persistentvolume-controller waiting for a volume to be created, either by external provisioner "blob.csi.azure.com" or manually created by system administrator + Normal ProvisioningSucceeded 8s blob.csi.azure.com_aks-nodepool1-34988195-vmss000002_8ecdf8ad-b636-4ca5-81ee-0f1a49337168 Successfully provisioned volume pvc-6db5af93-3b32-4c24-a68e-b727d7801fd5 +``` + +## Restore the PVC into a Pod + +```console +kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/blob-csi-driver/master/deploy/example/cloning/nginx-pod-restored-cloning.yaml +``` + +### Check Sample Data + +```console +$ kubectl exec nginx-blob-restored-cloning -- ls /mnt/blob +outfile +``` 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 000000000..77fe17dc4 --- /dev/null +++ b/deploy/example/cloning/nginx-pod-restored-cloning.yaml @@ -0,0 +1,21 @@ +--- +kind: Pod +apiVersion: v1 +metadata: + name: nginx-blob-restored-cloning +spec: + nodeSelector: + kubernetes.io/os: linux + containers: + - image: mcr.microsoft.com/oss/nginx/nginx:1.17.3-alpine + name: nginx-blob-restored-cloning + args: + - sleep + - "3600" + volumeMounts: + - name: blob-cloning + mountPath: "/mnt/blob" + volumes: + - name: blob-cloning + persistentVolumeClaim: + claimName: pvc-blob-cloning diff --git a/deploy/example/pvc-blob-csi-clone.yaml b/deploy/example/cloning/pvc-blob-csi-cloning.yaml similarity index 91% rename from deploy/example/pvc-blob-csi-clone.yaml rename to deploy/example/cloning/pvc-blob-csi-cloning.yaml index d24da9016..16d32b865 100644 --- a/deploy/example/pvc-blob-csi-clone.yaml +++ b/deploy/example/cloning/pvc-blob-csi-cloning.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: pvc-blob-clone + name: pvc-blob-cloning namespace: default spec: accessModes: diff --git a/hack/verify-yamllint.sh b/hack/verify-yamllint.sh index be491a816..6bdb1ffaa 100755 --- a/hack/verify-yamllint.sh +++ b/hack/verify-yamllint.sh @@ -29,7 +29,7 @@ if [[ "${deployDirNum}" != "${helmDirNum}" ]]; then exit 1 fi -for path in "deploy/*.yaml" "deploy/example/*.yaml" "deploy/example/metrics/*.yaml" +for path in "deploy/*.yaml" "deploy/example/*.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