Skip to content

Commit 87f8ecc

Browse files
杨尚坡spyang
authored andcommitted
support snapshot/clone
1 parent 77bd89f commit 87f8ecc

39 files changed

+1856
-186
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ in the Kubernetes documentation.
2525
## Develop
2626

2727
You can follow the [csi spec](https://github.com/container-storage-interface/spec/blob/master/spec.md)
28-
and [curve cli](docs/Curve%20Interface.md).
28+
and [curve interface](docs/curve-interface).
2929

3030
## Setup
3131

3232
1. Deploy the `curve tool` on the CO "Master" Hosts and `curve-nbd tool` on CO "Node" Hosts by the curve cluster provider.
3333
2. Choose a way to deploy the plugin:
3434

3535
- Using the helm chart: [helm installation](charts/curve-csi/README.md)
36-
- Using the kubernetes manifests: refer to the specific version in `deploy/kubernetes`
36+
- Using the kubernetes manifests: refer to the specific version in `deploy/manifests`
3737

3838
## Test and User Guide
3939

charts/curve-csi/templates/csi-daemonset.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ spec:
5252
image: "{{ .Values.nodeplugin.plugin.image }}"
5353
args:
5454
- --endpoint=$(CSI_ENDPOINT)
55-
{{- if .Values.common.curveVolumeNamingPrefix }}
56-
- "--curve-volume-prefix={{ .Values.common.curveVolumeNamingPrefix }}"
57-
{{- end }}
5855
- --drivername=curve.csi.netease.com
5956
- --nodeid=$(NODE_ID)
6057
{{- if .Values.nodeplugin.debug.enabled }}

charts/curve-csi/templates/csi-deployment.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,9 @@ spec:
114114
image: "{{ .Values.controllerplugin.plugin.image }}"
115115
args:
116116
- --endpoint=$(CSI_ENDPOINT)
117-
{{- if .Values.common.curveVolumeNamingPrefix }}
118-
- "--curve-volume-prefix={{ .Values.common.curveVolumeNamingPrefix }}"
119-
{{- end }}
120117
- --drivername=curve.csi.netease.com
121118
- --nodeid=$(NODE_ID)
119+
- --snapshot-server={{ .Values.controllerplugin.snapshotServer }}
122120
{{- if .Values.controllerplugin.debug.enabled }}
123121
- "--debug-port={{ .Values.controllerplugin.debug.port }}"
124122
{{- end }}

charts/curve-csi/values.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ nodeplugin:
2828
controllerplugin:
2929
replicas: 2
3030

31+
snapshotServer: http://127.0.0.1:5555
32+
3133
debug:
3234
enabled: true
3335
port: 9696
@@ -66,7 +68,3 @@ controllerplugin:
6668
tolerations: []
6769

6870
affinity: {}
69-
70-
# common variables
71-
common:
72-
curveVolumeNamingPrefix: ""

cmd/curve-csi.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ func init() {
4848
flag.BoolVar(&curveConf.IsNodeServer, "node-server", false, "start curve-csi node server")
4949
flag.BoolVar(&curveConf.IsControllerServer, "controller-server", false, "start curve-csi controller server")
5050

51-
// curve volume name prefix
52-
flag.StringVar(&curveConf.CurveVolumePrefix, "curve-volume-prefix", "csi-vol-", "curve volume name prefix")
51+
// curve snashot/clone server
52+
flag.StringVar(&curveConf.SnapshotServer, "snapshot-server", "http://127.0.0.1:5555", "curve snapshot/clone http server address, set empty to disable snapshot")
5353

5454
// debug
5555
flag.IntVar(&curveConf.DebugPort, "debug-port", 0, "debug port, set 0 to disable")

cmd/options/options.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ type CurveConf struct {
2626
IsControllerServer bool
2727
IsNodeServer bool
2828

29-
// curve volume namd prefix
30-
CurveVolumePrefix string
29+
// curve flags
30+
SnapshotServer string
3131

3232
// debugs
3333
DebugPort int

deploy/manifests/provisioner-deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ spec:
105105
- --endpoint=$(CSI_ENDPOINT)
106106
- --drivername=curve.csi.netease.com
107107
- --nodeid=$(NODE_ID)
108+
- "--snapshot-server=http://127.0.0.1:5555"
108109
- --controller-server=true
109110
- --debug-port=9696
110111
- --logtostderr=false

docs/README.md

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

33
This document provides more detail about curve-csi driver.
44

5+
- [Deploy](#deploy)
6+
- [Requirements](#requirements)
7+
- [Using the helm chart](#using-the-helm-chart)
8+
- [Using the kubernetes manifests](#using-the-kubernetes-manifests)
9+
- [Debug](#debug)
10+
- [Examples](#examples)
11+
- [Create StorageClass](#create-storageclass)
12+
- [Create PersistentVolumeClaim](#create-persistentvolumeclaim)
13+
- [Create Test Pod](#create-test-pod)
14+
- [Test block volume](#test-block-volume)
15+
- [Test volume expanding](#test-volume-expanding)
16+
- [Test snapshot](#test-snapshot)
17+
- [Test volume clone](#test-volume-clone)
18+
- [Test Using CSC Tool](#test-using-csc-tool)
19+
520
## Deploy
621

722
#### Requirements
@@ -36,7 +51,7 @@ and call:
3651
curl -XPUT http://127.0.0.1:<debugPort>/debug/flags/v -d '5'
3752
```
3853

39-
## Example
54+
## Examples
4055

4156
#### Create StorageClass
4257

@@ -93,8 +108,8 @@ spec:
93108
94109
```
95110
## create the pvc and pod:
96-
kubectl create -f ../examples/block/pvc.yaml
97-
kubectl create -f ../examples/block/pod.yaml
111+
kubectl create -f ../examples/pvc-block.yaml
112+
kubectl create -f ../examples/pod-block.yaml
98113

99114
## waiting for the pod running
100115
kubectl exec -it csi-curve-test-block bash
@@ -111,8 +126,23 @@ kubectl exec -it csi-curve-test-block bash
111126

112127
#### Test snapshot
113128

129+
Prerequisite: [install snapshot-controller](https://kubernetes-csi.github.io/docs/snapshot-controller.html)
130+
131+
132+
Create snapshot:
133+
134+
```
135+
kubectl create -f ../examples/snapshotclass.yaml
136+
kubectl create -f ../examples/snapshot.yaml
137+
```
138+
114139
#### Test volume clone
115140

141+
```
142+
kubectl create -f ../examples/pvc.yaml
143+
kubectl create -f ../examples/pvc-clone.yaml
144+
kubectl create -f ../examples/pvc-restore.yaml
145+
```
116146

117147
## Test Using CSC Tool
118148

@@ -164,6 +194,8 @@ $ csc controller create --endpoint tcp://127.0.0.1:10000 \
164194
"0003-k8s-csi-vol-volume-fa0c04c9-2e93-487e-8986-1e1625fd8c46" 10737418240 "user"="k8s"
165195
```
166196

197+
If the volume is block type, set: `--cap 5,1`
198+
167199
Check:
168200

169201
```text
@@ -190,16 +222,18 @@ $ csc node stage --endpoint tcp://127.0.0.1:10000 \
190222
0003-k8s-csi-vol-volume-fa0c04c9-2e93-487e-8986-1e1625fd8c46
191223
```
192224

225+
If the volume is block type, set: `--cap 5,1`
226+
193227
Check:
194228

195229
```text
196230
$ sudo curve-nbd list-mapped
197231
id image device
198232
97297 cbd:k8s//k8s/pvc-ce482926-91d8-11ea-bf6e-fa163e23ce53_k8s_ /dev/nbd0
199233
200-
$ sudo findmnt /mnt/test-csi/volume-globalmount
234+
$ sudo findmnt /mnt/test-csi/volume-globalmount/0003-k8s-csi-vol-volume-fa0c04c9-2e93-487e-8986-1e1625fd8c46
201235
TARGET SOURCE FSTYPE OPTIONS
202-
/mnt/test-csi/volume-globalmount /dev/nbd0 ext4 rw,relatime,data=ordered
236+
/mnt/test-csi/volume-globalmount/0003-k8s-csi-vol-volume-fa0c04c9-2e93-487e-8986-1e1625fd8c46 /dev/nbd0 ext4 rw,relatime,data=ordered
203237
```
204238

205239
#### NodePublish a volume
@@ -253,8 +287,8 @@ $ csc controller expand --endpoint tcp://127.0.0.1:10000 \
253287
254288
$ # nodeExpand:
255289
$ csc node expand --endpoint tcp://127.0.0.1:10000 \
256-
/mnt/test-csi/test-pod \
257-
0003-k8s-csi-vol-volume-fa0c04c9-2e93-487e-8986-1e1625fd8c46
290+
0003-k8s-csi-vol-volume-fa0c04c9-2e93-487e-8986-1e1625fd8c46 \
291+
/mnt/test-csi/test-pod
258292
0
259293
```
260294

@@ -317,3 +351,18 @@ $ sudo curve stat --user k8s --filename /k8s/csi-vol-volume-fa0c04c9-2e93-487e-8
317351
E 2020-08-24T13:57:55.946636+0800 58360 mds_client.cpp:395] GetFileInfo: filename = /k8s/volume-fa0c04c9-2e93-487e-8986-1e1625fd8c46, owner = k8s, errocde = 6, error msg = kFileNotExists, log id = 1
318352
stat fail, ret = -6
319353
```
354+
355+
#### Snapshot
356+
357+
```
358+
## create a snapshot
359+
$ csc controller create-snapshot --endpoint tcp://127.0.0.1:10000 \
360+
--source-volume 0003-k8s-csi-vol-volume-fa0c04c9-2e93-487e-8986-1e1625fd8c46 \
361+
snapshot-215d24ff-c04c-4b08-a1fb-692c94627c63
362+
"0024-9ea1a8fc-160d-47ef-b2ef-f0e09677b066-0003-k8s-csi-vol-volume-fa0c04c9-2e93-487e-8986-1e1625fd8c46" 23622320128 0003-k8s-csi-vol-volume-fa0c04c9-2e93-487e-8986-1e1625fd8c46 seconds:1639297566 nanos:780828000 true
363+
364+
## delete a snapshot
365+
$ csc controller delete-snapshot --endpoint tcp://127.0.0.1:10000 \
366+
0024-9ea1a8fc-160d-47ef-b2ef-f0e09677b066-0003-k8s-csi-vol-volume-fa0c04c9-2e93-487e-8986-1e1625fd8c46
367+
0024-9ea1a8fc-160d-47ef-b2ef-f0e09677b066-0003-k8s-csi-vol-volume-fa0c04c9-2e93-487e-8986-1e1625fd8c46
368+
```

docs/clone.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
### Verify if PVC is in Bound state
2+
3+
```bash
4+
$ kubectl get pvc
5+
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
6+
curve-test-pvc Bound pvc-b2789e09-9854-4aa1-b556-d9b0e0569f87 30Gi RWO curve 35m
7+
```
8+
9+
### Create a new cloned PVC
10+
11+
```
12+
kubectl create -f ../examples/pvc-clone.yaml
13+
```
14+
15+
### Get PVC
16+
17+
```bash
18+
$ kubectl get pvc curve-pvc-clone
19+
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
20+
curve-pvc-clone Bound pvc-755cfb47-9b03-41b5-bdf9-0772a1ae41ef 40Gi RWO curve 3s
21+
```
File renamed without changes.

0 commit comments

Comments
 (0)