Skip to content

Commit

Permalink
[csi] CreateSnapshot implementation (#86)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandr Stefurishin <[email protected]>
Signed-off-by: Aleksandr Zimin <[email protected]>
Co-authored-by: Aleksandr Zimin <[email protected]>
  • Loading branch information
Alexandr Stefurishin and AleksZimin authored Dec 5, 2024
1 parent 2460566 commit 68e0dc8
Show file tree
Hide file tree
Showing 16 changed files with 573 additions and 134 deletions.
54 changes: 53 additions & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,56 @@ while [[ $kubectl_completed_check -eq 0 ]]; do
kubectl_completed_check=`kubectl -n $ns get pods | grep migrate-pv-$src | grep "Completed" | wc -l`
done
echo "Data migration completed"
```
```

## How to Create Volume Snapshots?

You can read more about snapshots [here](https://kubernetes.io/docs/concepts/storage/volume-snapshots/).

### Step 1: Enabling the snapshot-controller

First, you need to enable the snapshot-controller:

```shell
kubectl apply -f -<<EOF
apiVersion: deckhouse.io/v1alpha1
kind: ModuleConfig
metadata:
name: snapshot-controller
spec:
enabled: true
version: 1
EOF

```

### Step 2: Creating a Volume Snapshot

Now you can create volume snapshots. To do this, execute the following command with the necessary parameters:

```shell
kubectl apply -f -<<EOF
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: my-snapshot
namespace: <name of the namespace where the PVC is located>
spec:
volumeSnapshotClassName: sds-local-volume-snapshot-class
source:
persistentVolumeClaimName: <name of the PVC to snapshot>
EOF
```

Note that `sds-local-volume-snapshot-class` is created automatically, and it's `deletionPolicy` is `Delete`, which means that `VolumeSnapshotContent` should be deleted when its bound `VolumeSnapshot` is deleted.


### Step 3: Checking the Snapshot Status

To check the status of the created snapshot, execute the command:

```shell
kubectl get volumesnapshot
```

This command will display a list of all snapshots and their current status.
4 changes: 2 additions & 2 deletions images/sds-local-volume-controller/src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module sds-local-volume-controller
go 1.22.2

require (
github.com/deckhouse/sds-local-volume/api v0.0.0-20240816081122-3de604d3d889
github.com/deckhouse/sds-node-configurator/api v0.0.0-20240926063625-6815fd9556ea
github.com/deckhouse/sds-local-volume/api v0.0.0-20241030133552-b9f48131ef9f
github.com/deckhouse/sds-node-configurator/api v0.0.0-20241104200552-c02b44d9b6a0
github.com/go-logr/logr v1.4.2
github.com/onsi/ginkgo/v2 v2.20.0
github.com/onsi/gomega v1.34.1
Expand Down
2 changes: 2 additions & 0 deletions images/sds-local-volume-controller/src/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ github.com/deckhouse/sds-node-configurator/api v0.0.0-20240925090458-249de289658
github.com/deckhouse/sds-node-configurator/api v0.0.0-20240925090458-249de2896583/go.mod h1:H71+9G0Jr46Qs0BA3z3/xt0h9lbnJnCEYcaCJCWFBf0=
github.com/deckhouse/sds-node-configurator/api v0.0.0-20240926063625-6815fd9556ea h1:RIbBqkoLvWHFNIpmq5LYObcwpRNWAEE6itzvwi/bvEQ=
github.com/deckhouse/sds-node-configurator/api v0.0.0-20240926063625-6815fd9556ea/go.mod h1:H71+9G0Jr46Qs0BA3z3/xt0h9lbnJnCEYcaCJCWFBf0=
github.com/deckhouse/sds-node-configurator/api v0.0.0-20241104200552-c02b44d9b6a0 h1:Clretr+LIIKah7IVlaN8MNNoLiF31pjIniS7zvCqqME=
github.com/deckhouse/sds-node-configurator/api v0.0.0-20241104200552-c02b44d9b6a0/go.mod h1:H71+9G0Jr46Qs0BA3z3/xt0h9lbnJnCEYcaCJCWFBf0=
github.com/emicklei/go-restful/v3 v3.12.1 h1:PJMDIM/ak7btuL8Ex0iYET9hxM3CI2sjZtzpL63nKAU=
github.com/emicklei/go-restful/v3 v3.12.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84=
Expand Down
Loading

0 comments on commit 68e0dc8

Please sign in to comment.