diff --git a/README.md b/README.md index 079c372641..cffd9442e0 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ This option does not depend on cloud provider config file, supports cross subscr - [NFS](./deploy/example/nfs) - [Snapshot](./deploy/example/snapshot) - [Resize](./deploy/example/resize) + - [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 0000000000..c9234afaf9 --- /dev/null +++ b/deploy/example/cloning/README.md @@ -0,0 +1,68 @@ +# Volume Cloning Example +## Feature Status: Beta + +- supported from v1.29.1 + +## Create a Source PVC + +```console +kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/storageclass-azurefile-csi.yaml +kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/pvc-azurefile-csi.yaml +kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/nginx-pod-azurefile.yaml +``` + +### Check the Source PVC + +```console +$ kubectl exec nginx-azurefile -- ls /mnt/azurefile +outfile +``` + +## Create a PVC from an existing PVC +> Make sure application is not writing data to source fileshare +```console +kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/cloning/pvc-azurefile-cloning.yaml +``` +### Check the Creation Status + +```console +$ kubectl describe pvc pvc-azurefile-cloning +Name: pvc-azurefile-cloning +Namespace: default +StorageClass: azurefile-csi +Status: Bound +Volume: pvc-bcbc953a-0232-457b-9100-6f1305c48b85 +Labels: +Annotations: pv.kubernetes.io/bind-completed: yes + pv.kubernetes.io/bound-by-controller: yes + volume.beta.kubernetes.io/storage-provisioner: file.csi.azure.com + volume.kubernetes.io/storage-provisioner: file.csi.azure.com +Finalizers: [kubernetes.io/pvc-protection] +Capacity: 100Gi +Access Modes: RWX +VolumeMode: Filesystem +DataSource: + Kind: PersistentVolumeClaim + Name: pvc-azurefile +Used By: +Events: + Type Reason Age From Message + ---- ------ ---- ---- ------- + Normal ExternalProvisioning 4m41s (x2 over 4m54s) persistentvolume-controller waiting for a volume to be created, either by external provisioner "file.csi.azure.com" or manually created by system administrator + Normal Provisioning 4m38s (x5 over 4m54s) file.csi.azure.com_aks-nodepool1-34988195-vmss000002_a240766c-7d4d-47f1-8f91-d97abbecad49 External provisioner is provisioning volume for claim "default/pvc-azurefile-cloning" + Normal ProvisioningSucceeded 4m30s file.csi.azure.com_aks-nodepool1-34988195-vmss000002_a240766c-7d4d-47f1-8f91-d97abbecad49 Successfully provisioned volume pvc-bcbc953a-0232-457b-9100-6f1305c48b85 +``` + +## Restore the PVC into a Pod + +```console +kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/cloning/nginx-pod-restored-cloning.yaml +``` + +### Check Sample Data + +```console +$ kubectl exec nginx-azurefile-restored-cloning -- ls /mnt/azurefile +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 0000000000..df181ecbb7 --- /dev/null +++ b/deploy/example/cloning/nginx-pod-restored-cloning.yaml @@ -0,0 +1,21 @@ +--- +kind: Pod +apiVersion: v1 +metadata: + name: nginx-azurefile-restored-cloning +spec: + nodeSelector: + kubernetes.io/os: linux + containers: + - image: mcr.microsoft.com/oss/nginx/nginx:1.17.3-alpine + name: nginx-azurefile-restored-cloning + args: + - sleep + - "3600" + volumeMounts: + - name: azurefile-cloning + mountPath: "/mnt/azurefile" + volumes: + - name: azurefile-cloning + persistentVolumeClaim: + claimName: pvc-azurefile-cloning diff --git a/deploy/example/pvc-azurefile-csi-clone.yaml b/deploy/example/cloning/pvc-azurefile-cloning.yaml similarity index 90% rename from deploy/example/pvc-azurefile-csi-clone.yaml rename to deploy/example/cloning/pvc-azurefile-cloning.yaml index 10cc1a1c89..d5657e3145 100644 --- a/deploy/example/pvc-azurefile-csi-clone.yaml +++ b/deploy/example/cloning/pvc-azurefile-cloning.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: pvc-azurefile-clone + name: pvc-azurefile-cloning namespace: default spec: accessModes: diff --git a/hack/verify-yamllint.sh b/hack/verify-yamllint.sh index eb1a57de65..667f98a733 100755 --- a/hack/verify-yamllint.sh +++ b/hack/verify-yamllint.sh @@ -21,7 +21,7 @@ fi LOG=/tmp/yamllint.log helmPath=charts/latest/azurefile-csi-driver/templates -for path in "deploy/*.yaml" "deploy/example/*.yaml" "deploy/example/snapshot/*.yaml" "deploy/example/disk/*.yaml" "deploy/example/windows/*.yaml" "deploy/example/metrics/*.yaml" "deploy/example/largeFileShares/*.yaml" "deploy/example/smb-provisioner/*.yaml" +for path in "deploy/*.yaml" "deploy/example/*.yaml" "deploy/example/snapshot/*.yaml" "deploy/example/disk/*.yaml" "deploy/example/windows/*.yaml" "deploy/example/metrics/*.yaml" "deploy/example/largeFileShares/*.yaml" "deploy/example/smb-provisioner/*.yaml" "deploy/example/cloning/*.yaml" do echo "checking yamllint under path: $path ..." yamllint -f parsable $path | grep -v "line too long" > $LOG