Skip to content

Commit 02306da

Browse files
authored
Merge pull request #31 from jingxu97/readme
Add more contents to readme file
2 parents 5ed076f + 64d036d commit 02306da

File tree

1 file changed

+63
-2
lines changed

1 file changed

+63
-2
lines changed

README.md

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,66 @@
1-
# external-snapshotter
2-
Sidecar container that watches Kubernetes Snapshot CRD objects and triggers CreateSnapshot/DeleteSnapshot against a CSI endpoint.
1+
# CSI Snapshotter
2+
3+
The CSI external-snapshotter is part of Kubernetes implementation of [Container Storage Interface (CSI)](https://github.com/container-storage-interface/spec)
4+
5+
## Overview
6+
7+
CSI Snapshotter is an external controller that watches Kubernetes Snapshot CRD objects and triggers CreateSnapshot/DeleteSnapshot against a CSI endpoint. Full design can be found at Kubernetes proposal at [here](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/storage/csi-snapshot.md)
8+
9+
## Design
10+
11+
External snapshotter follows [controller](https://github.com/kubernetes/community/blob/master/contributors/devel/controllers.md) pattern and uses informers to watch for `VolumeSnapshot` and `VolumeSnapshotContent` create/update/delete events. It filters out these objects with `Snapshotter==<CSI driver name>` specified in the associated VolumeSnapshotClass object and then processes these events in workqueues with exponential backoff.
12+
13+
### Snapshotter
14+
15+
Snapshotter talks to CSI over socket (/run/csi/socket by default, configurable by -csi-address). The snapshotter then:
16+
17+
* Discovers the supported snapshotter name by `GetDriverName` call.
18+
19+
* Uses ControllerGetCapabilities for find out if CSI driver supports `ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT` and `ControllerServiceCapability_RPC_LIST_SNAPSHOTS` calls. Otherwise, the controller will not start.
20+
21+
* Processes new/updated/deleted `VolumeSnapshots`: The snapshotter only processes `VolumeSnapshot` that has `snapshotter` specified in its `VolumeSnapshotClass` matches its driver name. The process workflow is as follows
22+
* If the snapshot status is `Ready`, the controller checks whether the snapshot and its content still binds correctly. If there is any problem with the binding (e.g., snapshot points to a non-exist snapshot content), update the snapshot status and emit event.
23+
* If the snapshot status is not ready, there are two cases.
24+
* `SnapshotContentName` is not empty: the controller verifies whether the snapshot content exists and also binds to the snapshot. If verification passes, the controller binds the snapshot and its content objects and marks it is ready. Otherwise, it updates the error status of the snapshot.
25+
* `SnapshotContentName` is set empty: the controller will first check whether there is already a content object which binds the snapshot correctly with snapshot uid (`VolumeSnapshotRef.UID`) specified. If so, the controller binds these two objects. Otherwise, the controller issues a create snapshot operation. Please note that if the error status shows that snapshot creation already failed before, it will not try to create snapshot again.
26+
27+
28+
* Processes new/updated/deleted `VolumeSnapshotContents`: The snapshotter only processes `VolumeSnapshotContent` in which the CSI driver specified in the spec matches the controller's driver name.
29+
* If the `VolumeSnapshotRef` is set to nil, skip this content since it is not bound to any snapshot object.
30+
* Otherwise, the controller verifies whether the content object is correctly bound to a snapshot object. In case the `VolumeSnapshotRef.UID` is set but it does not match its snapshot object or snapshot no long exists, the content object and its associated snapshot will be deleted.
31+
32+
## Usage
33+
34+
### Running on command line
35+
36+
For debugging, it is possible to run snapshotter on command line. For example,
37+
38+
```
39+
$ csi-snapshotter -kubeconfig ~/.kube/config -v 5 -csi-address /run/csi/socket
40+
```
41+
42+
### Running in a statefulset
43+
44+
It is necessary to create a new service account and give it enough privileges to run the snapshotter. We provide one omnipotent yaml file that creates everything that's necessary, however it should be split into multiple files in production.
45+
46+
```
47+
$ kubectl create deploy/kubernetes/statefulset.yaml
48+
```
49+
50+
## Testing
51+
52+
Running Unit Tests:
53+
```
54+
$ go test -timeout 30s github.com/kubernetes-csi/external-snapshotter/pkg/controller
55+
```
56+
57+
## Dependency Management
58+
59+
```
60+
$ dep ensure
61+
```
62+
63+
To modify dependencies or versions change `./Gopkg.toml`
364

465
## Community, discussion, contribution, and support
566

0 commit comments

Comments
 (0)