Skip to content

Commit

Permalink
Merge pull request #1601 from umagnus/release-1.29
Browse files Browse the repository at this point in the history
[release-1.29] doc: add volume cloning doc
  • Loading branch information
andyzhangx authored Nov 24, 2023
2 parents 4f98c74 + d38969c commit 69bfdea
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
68 changes: 68 additions & 0 deletions deploy/example/cloning/README.md
Original file line number Diff line number Diff line change
@@ -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: <none>
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: <none>
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
```

21 changes: 21 additions & 0 deletions deploy/example/cloning/nginx-pod-restored-cloning.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-azurefile-clone
name: pvc-azurefile-cloning
namespace: default
spec:
accessModes:
Expand Down
2 changes: 1 addition & 1 deletion hack/verify-yamllint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 69bfdea

Please # to comment.