Skip to content

Commit

Permalink
Merge pull request #698 from umagnus/add_volume_cloning_doc
Browse files Browse the repository at this point in the history
doc: add volume cloning doc
  • Loading branch information
k8s-ci-robot authored Nov 30, 2023
2 parents 1baba7d + c1813fa commit 8f2aa14
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
66 changes: 66 additions & 0 deletions deploy/example/cloning/README.md
Original file line number Diff line number Diff line change
@@ -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: <none>
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: <none>
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
```
20 changes: 20 additions & 0 deletions deploy/example/cloning/nginx-pod-restored-cloning.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-smb-clone
name: pvc-smb-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 @@ -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
Expand Down

0 comments on commit 8f2aa14

Please sign in to comment.