Skip to content

Commit 023b7f8

Browse files
committed
add volume cloning doc
1 parent e1ce605 commit 023b7f8

File tree

6 files changed

+114
-2
lines changed

6 files changed

+114
-2
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Please refer to [`nfs.csi.k8s.io` driver parameters](./docs/driver-parameters.md
2727
### Examples
2828
- [Basic usage](./deploy/example/README.md)
2929
- [fsGroupPolicy](./deploy/example/fsgroup)
30+
- [Volume cloning](./deploy/example/cloning)
3031

3132
### Troubleshooting
3233
- [CSI driver troubleshooting guide](./docs/csi-debug.md)

deploy/example/cloning/README.md

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Volume Cloning Example
2+
3+
- supported from v4.3.0
4+
5+
## Create a Source PVC
6+
7+
```console
8+
kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/deploy/example/storageclass-nfs.yaml
9+
kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/deploy/example/pvc-nfs-csi-dynamic.yaml
10+
kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/deploy/example/nginx-pod-nfs.yaml
11+
```
12+
13+
### Check the Source PVC
14+
15+
```console
16+
$ kubectl exec nginx-nfs -- ls /mnt/nfs
17+
outfile
18+
```
19+
20+
## Create a PVC from an existing PVC
21+
> Make sure application is not writing data to source nfs share
22+
```console
23+
kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/deploy/example/cloning/pvc-nfs-cloning.yaml
24+
```
25+
### Check the Creation Status
26+
27+
```console
28+
$ kubectl describe pvc pvc-nfs-cloning
29+
Name: pvc-nfs-cloning
30+
Namespace: default
31+
StorageClass: nfs-csi
32+
Status: Bound
33+
Volume: pvc-5a00da0e-9afe-40f7-9f52-edabcf28df63
34+
Labels: <none>
35+
Annotations: kubectl.kubernetes.io/last-applied-configuration:
36+
{"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{},"name":"pvc-nfs-cloning","namespace":"default"},"spec":{"ac...
37+
pv.kubernetes.io/bind-completed: yes
38+
pv.kubernetes.io/bound-by-controller: yes
39+
volume.beta.kubernetes.io/storage-provisioner: nfs.csi.k8s.io
40+
volume.kubernetes.io/storage-provisioner: nfs.csi.k8s.io
41+
Finalizers: [kubernetes.io/pvc-protection]
42+
Capacity: 10Gi
43+
Access Modes: RWX
44+
VolumeMode: Filesystem
45+
Mounted By: <none>
46+
Events:
47+
Type Reason Age From Message
48+
---- ------ ---- ---- -------
49+
Normal ExternalProvisioning 5s persistentvolume-controller waiting for a volume to be created, either by external provisioner "nfs.csi.k8s.io" or manually created by system administrator
50+
Normal Provisioning 5s nfs.csi.k8s.io_aks-nodepool1-34988195-vmss000000_534f1e86-3a71-4ca4-9b83-803c05a44d65 External provisioner is provisioning volume for claim "default/pvc-nfs-cloning"
51+
Normal ProvisioningSucceeded 5s nfs.csi.k8s.io_aks-nodepool1-34988195-vmss000000_534f1e86-3a71-4ca4-9b83-803c05a44d65 Successfully provisioned volume pvc-5a00da0e-9afe-40f7-9f52-edabcf28df63
52+
```
53+
54+
## Restore the PVC into a Pod
55+
56+
```console
57+
kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/deploy/example/cloning/nginx-pod-restored-cloning.yaml
58+
```
59+
60+
### Check Sample Data
61+
62+
```console
63+
$ kubectl exec nginx-nfs-restored-cloning -- ls /mnt/nfs
64+
outfile
65+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
kind: Pod
3+
apiVersion: v1
4+
metadata:
5+
name: nginx-nfs-restored-cloning
6+
spec:
7+
nodeSelector:
8+
"kubernetes.io/os": linux
9+
containers:
10+
- image: mcr.microsoft.com/oss/nginx/nginx:1.19.5
11+
name: nginx-nfs
12+
command:
13+
- "/bin/bash"
14+
- "-c"
15+
- set -euo pipefail; while true; do echo $(date) >> /mnt/nfs/outfile; sleep 1; done
16+
volumeMounts:
17+
- name: persistent-storage
18+
mountPath: "/mnt/nfs"
19+
readOnly: false
20+
volumes:
21+
- name: persistent-storage
22+
persistentVolumeClaim:
23+
claimName: pvc-nfs-cloning

deploy/example/pvc-volume-clone.yaml renamed to deploy/example/cloning/pvc-nfs-cloning.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: v1
33
kind: PersistentVolumeClaim
44
metadata:
5-
name: pvc-nfs-clone
5+
name: pvc-nfs-cloning
66
namespace: default
77
spec:
88
accessModes:

deploy/example/nginx-pod-nfs.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
kind: Pod
3+
apiVersion: v1
4+
metadata:
5+
name: nginx-nfs
6+
spec:
7+
nodeSelector:
8+
"kubernetes.io/os": linux
9+
containers:
10+
- image: mcr.microsoft.com/oss/nginx/nginx:1.19.5
11+
name: nginx-nfs
12+
command:
13+
- "/bin/bash"
14+
- "-c"
15+
- set -euo pipefail; while true; do echo $(date) >> /mnt/nfs/outfile; sleep 1; done
16+
volumeMounts:
17+
- name: persistent-storage
18+
mountPath: "/mnt/nfs"
19+
readOnly: false
20+
volumes:
21+
- name: persistent-storage
22+
persistentVolumeClaim:
23+
claimName: pvc-nfs-dynamic

hack/verify-yamllint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if [[ "${deployDirNum}" != "${helmDirNum}" ]]; then
2929
exit 1
3030
fi
3131

32-
for path in "deploy/*.yaml" "deploy/example/*.yaml" "deploy/example/nfs-provisioner/*.yaml"
32+
for path in "deploy/*.yaml" "deploy/example/*.yaml" "deploy/example/nfs-provisioner/*.yaml" "deploy/example/cloning/*.yaml"
3333
do
3434
echo "checking yamllint under path: $path ..."
3535
yamllint -f parsable $path | grep -v "line too long" > $LOG

0 commit comments

Comments
 (0)