Skip to content

Commit 1360f37

Browse files
authored
Merge pull request #600 from leonardoce/doc_group_snapshot
Add documentation for volume group snapshot
2 parents b1d0dd5 + b736bc1 commit 1360f37

7 files changed

+194
-10
lines changed

book/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
- [Data Sources](volume-datasources.md)
3434
- [Cloning](volume-cloning.md)
3535
- [Volume Snapshot & Restore](snapshot-restore-feature.md)
36+
- [Volume Group Snapshot & Restore](group-snapshot-restore-feature.md)
3637
- [Ephemeral Local Volumes](ephemeral-local-volumes.md)
3738
- [Volume Limits](volume-limits.md)
3839
- [Storage Capacity Tracking](storage-capacity-tracking.md)

book/src/external-snapshotter.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@ To use the snapshot beta and GA feature, a snapshot controller is also required.
3434

3535
### Description
3636

37-
Starting with the Beta version, the snapshot controller will be watching the Kubernetes API server for `VolumeSnapshot` and `VolumeSnapshotContent` CRD objects. The CSI `external-snapshotter` sidecar only watches the Kubernetes API server for `VolumeSnapshotContent` CRD objects. The CSI `external-snapshotter` sidecar is also responsible for calling the CSI RPCs CreateSnapshot, DeleteSnapshot, and ListSnapshots.
37+
The CSI `external-snapshotter` sidecar watches the Kubernetes API server for `VolumeSnapshotContent` CRD objects. The CSI `external-snapshotter` sidecar is also responsible for calling the CSI RPCs `CreateSnapshot`, `DeleteSnapshot`, and `ListSnapshots`.
3838

39-
#### VolumeSnapshotClass Parameters
39+
Volume Group Snapshot support can be enabled with the `--enable-volume-group-snapshots` option. When enabled, the CSI `external-snapshotter` sidecar watches the API server for `VolumeGroupSnapshotContent` CRD object, and will be responsible for calling the CSI RPCs `CreateVolumeGroupSnapshot`, `DeleteVolumeGroupSnapshot` and `GetVolumeGroupSnapshot`.
40+
41+
#### VolumeSnapshotClass and VolumeGroupSnapshotClass Parameters
4042

4143
When provisioning a new volume snapshot, the CSI `external-snapshotter` sets the `map<string, string> parameters` field in the CSI `CreateSnapshotRequest` call to the key/values specified in the `VolumeSnapshotClass` it is handling.
4244

43-
The CSI `external-snapshotter` also reserves the parameter keys prefixed with `csi.storage.k8s.io/`. Any `VolumeSnapshotClass` keys prefixed with `csi.storage.k8s.io/` are not passed to the CSI driver as an opaque `parameter`.
45+
When volume group snapshot support is enabled, the `map<string, string> parameters` field is set in the CSI `CreateVolumeGroupSnapshotRequest` call to the key/values specified in the `VolumeGroupSnapshotClass` it is handling.
46+
47+
The CSI `external-snapshotter` also reserves the parameter keys prefixed with `csi.storage.k8s.io/`. Any `VolumeSnapshotClass` or `VolumeGroupSnapshotClass` keys prefixed with `csi.storage.k8s.io/` are not passed to the CSI driver as an opaque `parameter`.
4448

4549
The following reserved `VolumeSnapshotClass` parameter keys trigger behavior in the CSI `external-snapshotter`:
4650

@@ -51,9 +55,9 @@ The following reserved `VolumeSnapshotClass` parameter keys trigger behavior in
5155

5256
For more information on how secrets are handled see [Secrets & Credentials](secrets-and-credentials.md).
5357

54-
#### VolumeSnapshot and VolumeSnapshotContent Parameters
58+
#### VolumeSnapshot, VolumeSnapshotContent, VolumeGroupSnapshot and VolumeGroupSnapshotContent Parameters
5559

56-
The CSI `external-snapshotter` (v4.0.0+) introduces the `--extra-create-metadata` flag, which automatically sets the following `map<string, string> parameters` in the CSI `CreateSnapshotRequest`:
60+
The CSI `external-snapshotter` (v4.0.0+) introduces the `--extra-create-metadata` flag, which automatically sets the following `map<string, string> parameters` in the CSI `CreateSnapshotRequest` and `CreateVolumeGroupSnapshotRequest`:
5761

5862
* `csi.storage.k8s.io/volumesnapshot/name`
5963
* `csi.storage.k8s.io/volumesnapshot/namespace`
@@ -69,6 +73,8 @@ For detailed information about volume snapshot and restore functionality, see [V
6973

7074
CSI drivers that support provisioning volume snapshots and the ability to provision new volumes using those snapshots should use this sidecar container, and advertise the CSI `CREATE_DELETE_SNAPSHOT` controller capability.
7175

76+
CSI drivers that support provisioning volume group snapshots should use this side container too, and advertise the CSI `CREATE_DELETE_GET_VOLUME_GROUP_SNAPSHOT` controller capability.
77+
7278
For detailed information (binary parameters, RBAC rules, etc.), see [https://github.com/kubernetes-csi/external-snapshotter/blob/release-6.2/README.md](https://github.com/kubernetes-csi/external-snapshotter/blob/release-6.2/README.md).
7379

7480
### Deployment
+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Volume Group Snapshot Feature
2+
3+
## Status
4+
5+
Status | Min K8s Version | Max K8s Version | snapshot-controller Version | snapshot-validation-webhook Version | CSI external-snapshotter sidecar Version | external-provisioner Version
6+
--|--|--|--|--|--|--
7+
Alpha | 1.27 | - | 7.0+ | 7.0+ | 7.0+ | 4.0+
8+
9+
**IMPORTANT**: The validation logic for VolumeGroupSnapshots and VolumeGroupSnapshotContents has been replaced by CEL validation rules. The validating webhook is now only being used for VolumeGroupSnapshotClasses to ensure that there's at most one default class per CSI Driver. The validation webhook is deprecated and will be removed in the next release
10+
11+
## Overview
12+
13+
Some storage systems provide the ability to create a crash consistent snapshot of
14+
multiple volumes. A group snapshot represents “copies” from multiple volumes that
15+
are taken at the same point-in-time. A group snapshot can be used either to rehydrate
16+
new volumes (pre-populated with the snapshot data) or to restore existing volumes to
17+
a previous state (represented by the snapshots).
18+
19+
Kubernetes CSI currently enables CSI Drivers to expose the following
20+
functionality via the Kubernetes API:
21+
22+
1. Creation and deletion of volume group snapshots via [Kubernetes native
23+
API](https://github.com/kubernetes-csi/external-snapshotter/tree/master/client/apis/volumegroupsnapshot/v1alpha1).
24+
2. Creation of new volumes pre-populated with the data from a snapshot that is
25+
part of the volume group snapshot via Kubernetes [dynamic volume
26+
provisioning](https://kubernetes.io/docs/concepts/storage/dynamic-provisioning/).
27+
28+
## Implementing Volume Group Snapshot Functionality in your CSI Driver
29+
30+
To implement the volume group snapshot feature, a CSI driver MUST:
31+
32+
* Implement a new group controller service.
33+
* Implement group controller RPCs: `CreateVolumeGroupSnapshot`, `DeleteVolumeGroupSnapshot`, and `GetVolumeGroupSnapshot`.
34+
* Add group controller capability `CREATE_DELETE_GET_VOLUME_GROUP_SNAPSHOT`.
35+
36+
For details, see the [CSI spec](https://github.com/container-storage-interface/spec/blob/master/spec.md).
37+
38+
## Sidecar Deployment
39+
40+
The Kubernetes CSI development team maintains the
41+
[external-snapshotter](external-snapshotter.md) Kubernetes CSI [Sidecar
42+
Containers](sidecar-containers.md). This sidecar container implements the logic
43+
for watching the Kubernetes API objects and issuing the appropriate CSI volume
44+
group snapshot calls against a CSI endpoint. For more details, see
45+
[external-snapshotter documentation](external-snapshotter.md).
46+
47+
## Volume Group Snapshot APIs
48+
49+
With the introduction of Volume Group Snapshot, the user can create and delete a
50+
group snapshot using Kubernetes APIs.
51+
52+
The schema definition for the custom resources (CRs) can be found
53+
[here](https://github.com/kubernetes-csi/external-snapshotter/tree/master/client/config/crd).
54+
The CRDs should be installed by the Kubernetes distributions.
55+
56+
There are 3 APIs:
57+
58+
`VolumeGroupSnapshot`
59+
: Created by a Kubernetes user (or perhaps by your own automation) to request
60+
creation of a volume group snapshot for multiple volumes.
61+
It contains information about the volume group snapshot operation such as the
62+
timestamp when the volume group snapshot was taken and whether it is ready to use.
63+
The creation and deletion of this object represents a desire to create or delete a
64+
cluster resource (a group snapshot).
65+
66+
`VolumeGroupSnapshotContent`
67+
: Created by the snapshot controller for a dynamically created VolumeGroupSnapshot.
68+
It contains information about the volume group snapshot including the volume group
69+
snapshot ID.
70+
This object represents a provisioned resource on the cluster (a group snapshot).
71+
The VolumeGroupSnapshotContent object binds to the VolumeGroupSnapshot for which it
72+
was created with a one-to-one mapping.
73+
74+
`VolumeGroupSnapshotClass`
75+
: Created by cluster administrators to describe how volume group snapshots should be
76+
created. including the driver information, the deletion policy, etc.
77+
78+
## Controller
79+
80+
* The controller logic for volume group snapshot is added to the snapshot
81+
controller and the CSI external-snapshotter sidecar.
82+
83+
The snapshot controller is deployed by the Kubernetes distributions and is
84+
responsible for watching the VolumeGroupSnapshot CRD objects and manges the
85+
creation and deletion lifecycle of volume group snapshots.
86+
87+
The CSI external-snapshotter sidecar watches Kubernetes
88+
VolumeGroupSnapshotContent CRD objects and triggers
89+
CreateVolumeGroupSnapshot/DeleteVolumeGroupSnapshot against a CSI endpoint.
90+
91+
## Snapshot Validation Webhook
92+
93+
The validating webhook server is updated to validate volume group snapshot
94+
objects. This SHOULD be installed by the Kubernetes distros along with the
95+
snapshot-controller, not end users. It SHOULD be installed in all Kubernetes
96+
clusters that has the volume group snapshot feature enabled. See [Snapshot
97+
Validation Webhook](snapshot-validation-webhook.md) for more details on how to
98+
use the webhook.
99+
100+
## Kubernetes Cluster Setup
101+
102+
See the Deployment section of [Snapshot Controller](snapshot-controller.md) on
103+
how to set up the snapshot controller and CRDs.
104+
105+
See the Deployment section of [Snapshot Validation
106+
Webhook](snapshot-validation-webhook.md) for more details on how to use the
107+
webhook.
108+
109+
## Test Volume Group Snapshot Feature
110+
111+
To test volume group snapshot version, use the following [example yaml files](https://github.com/kubernetes-csi/external-snapshotter/tree/master/examples/kubernetes).
112+
113+
Create a _StorageClass_:
114+
```
115+
kubectl create -f storageclass.yaml
116+
```
117+
118+
Create _PVCs_:
119+
```
120+
# This will create a PVC named hpvc
121+
kubectl create -f pvc.yaml
122+
123+
# This will create a PVC named hpvc-2
124+
sed "s/hpvc/hpvc-2/" pvc.yaml | kubectl create -f -
125+
```
126+
127+
Add a label to _PVC_:
128+
```
129+
kubectl label pvc hpvc hpvc-2 app.kubernetes.io/name=postgresql
130+
```
131+
132+
Create a _VolumeGroupSnapshotClass_:
133+
```
134+
kubectl create -f groupsnapshotclass-v1alpha1.yaml
135+
```
136+
137+
Create a _VolumeGroupSnapshot_:
138+
```
139+
kubectl create -f groupsnapshot-v1alpha1.yaml
140+
```
141+
142+
Once the _VolumeGroupSnapshot_ is ready, the `pvcVolumeSnapshotRefList` status field will contain the names of the generated _VolumeSnapshot_ objects:
143+
```
144+
kubectl get volumegroupsnapshot new-groupsnapshot-demo -o yaml | sed -n '/pvcVolumeSnapshotRefList/,$p'
145+
146+
pvcVolumeSnapshotRefList:
147+
- persistentVolumeClaimRef:
148+
name: hpvc
149+
volumeSnapshotRef:
150+
name: snapshot-4bcc4a322a473abf32babe3df5779d14349542b1f0eb6f9dab0466a85c59cd42-2024-06-19-12.35.17
151+
- persistentVolumeClaimRef:
152+
name: hpvc-2
153+
volumeSnapshotRef:
154+
name: snapshot-62bd0be591e1e10c22d51748cd4a53c0ae8bf52fabb482bee7bc51f8ff9d9589-2024-06-19-12.35.17
155+
readyToUse: true
156+
```
157+
158+
Create a _PVC_ from a _VolumeSnapshot_ that is part of the group snapshot:
159+
```
160+
# In the command below, the volume snapshot name should be chosen from
161+
# the ones listed in the output of the previous command
162+
sed 's/new-snapshot-demo-v1/snapshot-4bcc4a322a473abf32babe3df5779d14349542b1f0eb6f9dab0466a85c59cd42-2024-06-19-12.35.17/' restore.yaml | kubectl create -f -
163+
```
164+
165+
## Examples
166+
167+
See the [Drivers](drivers.md) for a list of CSI drivers that implement the group snapshot feature.

book/src/group-snapshot.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Volume Group Snapshot & Restore

book/src/sidecar-containers.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Kubernetes CSI Sidecar Containers
22

3-
Kubernetes CSI Sidecar Containers are a set of standard containers that aim to simplify the development and deployment of CSI Drivers on Kubernetes.
3+
Kubernetes CSI Sidecar Containers are a set of standard containers that aim to
4+
simplify the development and deployment of CSI Drivers on Kubernetes.
45

5-
These containers contain common logic to watch the Kubernetes API, trigger appropriate operations against the “CSI volume driver” container, and update the Kubernetes API as appropriate.
6+
These containers contain common logic to watch the Kubernetes API, trigger
7+
appropriate operations against the “CSI volume driver” container, and update the
8+
Kubernetes API as appropriate.
69

710
The containers are intended to be bundled with third-party CSI driver containers and deployed together as pods.
811

book/src/snapshot-controller.md

+4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@ For more information on the CSI external-snapshotter sidecar, see [this external
3434

3535
The snapshot controller will be watching the Kubernetes API server for `VolumeSnapshot` and `VolumeSnapshotContent` CRD objects. The CSI `external-snapshotter` sidecar only watches the Kubernetes API server for `VolumeSnapshotContent` CRD objects. The snapshot controller will be creating the `VolumeSnapshotContent` CRD object which triggers the CSI `external-snapshotter` sidecar to create a snapshot on the storage system.
3636

37+
The snapshot controller will be watching for `VolumeGroupSnapshot` and `VolumeGroupSnapshotContent` CRD objects when Volume Group Snapshot support is enabled via the `--enable-volume-group-snapshots` option.
38+
3739
For detailed snapshot beta design changes, see the design doc [here](https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/177-volume-snapshot/README.md).
3840

3941
For detailed information about volume snapshot and restore functionality, see [Volume Snapshot & Restore](snapshot-restore-feature.md).
4042

43+
For detailed information about volume group snapshot and restore functionality, see [Volume Snapshot & Restore](group-snapshot.md).
44+
4145
For detailed information (binary parameters, RBAC rules, etc.), see [https://github.com/kubernetes-csi/external-snapshotter/blob/release-6.2/README.md](https://github.com/kubernetes-csi/external-snapshotter/blob/release-6.2/README.md).
4246

4347
## Deployment

book/src/snapshot-restore-feature.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Alpha | 1.12 | 1.12 | | | 0.4.0 <= version < 1.0 | 0.4.1 <= version < 1.0
88
Alpha | 1.13 | 1.16 | | | 1.0.1 <= version < 2.0 | 1.0.1 <= version < 1.5
99
Beta | 1.17 | - | 2.0+ | 3.0+ | 2.0+ | 1.5+
1010

11+
**IMPORTANT**: The validation logic for VolumeSnapshots and VolumeSnapshotContents has been replaced by CEL validation rules. The validating webhook is now only being used for VolumeSnapshotClasses to ensure that there's at most one default class per CSI Driver. The validation webhook is deprecated and will be removed in the next release.
12+
1113
## Overview
1214

1315
Many storage systems provide the ability to create a "snapshot" of a persistent volume. A snapshot represents a point-in-time copy of a volume. A snapshot can be used either to provision a new volume (pre-populated with the snapshot data) or to restore the existing volume to a previous state (represented by the snapshot).
@@ -83,12 +85,12 @@ kubectl create -f pvc.yaml
8385

8486
Create a _VolumeSnapshotClass_:
8587
```
86-
kubectl create -f snapshotclass.yaml
88+
kubectl create -f snapshotclass-v1.yaml
8789
```
8890

8991
Create a _VolumeSnapshot_:
9092
```
91-
kubectl create -f snapshot.yaml
93+
kubectl create -f snapshot-v1.yaml
9294
```
9395

9496
Create a _PVC_ from a _VolumeSnapshot_:
@@ -143,7 +145,7 @@ kubectl create -f snapshot.yaml
143145

144146
Create a _PVC_ from a _VolumeSnapshot_:
145147
```
146-
kuberctl create -f restore.yaml
148+
kubectl create -f restore.yaml
147149
```
148150

149151
#### PersistentVolumeClaim not Bound

0 commit comments

Comments
 (0)