Skip to content

Commit 4111de6

Browse files
authored
Merge pull request #114269 from lpettyjo/OSDOCS-16947-csi-snapshots
OSDOCS-16947#CQA work Stor3 - CSI snapshots
2 parents 6cd5c20 + fce86f5 commit 4111de6

9 files changed

Lines changed: 188 additions & 92 deletions

modules/persistent-storage-csi-snapshots-controller-sidecar.adoc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
[id="persistent-storage-csi-snapshots-controller-sidecar_{context}"]
77
= CSI snapshot controller and sidecar
88

9-
{product-title} provides a snapshot controller that is deployed into the control plane. In addition, your CSI driver vendor provides the CSI snapshot sidecar as a helper container that is installed during the CSI driver installation.
9+
[role="_abstract"]
10+
Container Storage Interface (CSI) snapshots require two components: a controller deployed by {product-title} to the control plane, and a vendor-provided sidecar with the CSI driver. The controller manages `VolumeSnapshot` bindings while the sidecar triggers create and delete operations.
1011

1112
The CSI snapshot controller and sidecar provide volume snapshotting through the {product-title} API. These external components run in the cluster.
1213

1314
The external controller is deployed by the CSI Snapshot Controller Operator.
1415

15-
== External controller
16-
The CSI snapshot controller binds `VolumeSnapshot` and `VolumeSnapshotContent` objects. The controller manages dynamic provisioning by creating and deleting `VolumeSnapshotContent` objects.
16+
External controller:: The CSI snapshot controller binds `VolumeSnapshot` and `VolumeSnapshotContent` objects. The controller manages dynamic provisioning by creating and deleting `VolumeSnapshotContent` objects.
1717

18-
== External sidecar
19-
Your CSI driver vendor provides the `csi-external-snapshotter` sidecar. This is a separate helper container that is deployed with the CSI driver. The sidecar manages snapshots by triggering `CreateSnapshot` and `DeleteSnapshot` operations. Follow the installation instructions provided by your vendor.
18+
External sidecar:: Your CSI driver vendor provides the `csi-external-snapshotter` sidecar. This is a separate helper container that is deployed with the CSI driver. The sidecar manages snapshots by triggering `CreateSnapshot` and `DeleteSnapshot` operations. Follow the installation instructions provided by your vendor.
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * storage/container_storage_interface/persistent-storage-csi-snapshots.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="persistent-storage-csi-snapshots-create-static_{context}"]
7+
= Statically creating a volume snapshot
8+
9+
[role="_abstract"]
10+
To make a pre-existing storage snapshot available in {product-title}, manually create a volume snapshot that references the existing snapshot content by name.
11+
12+
.Prerequisites
13+
* Logged in to a running {product-title} cluster.
14+
* A PVC created using a CSI driver that supports `VolumeSnapshot` objects.
15+
* A storage class to provision the storage back end.
16+
* No pods are using the persistent volume claim (PVC) that you want to take a snapshot of.
17+
+
18+
[WARNING]
19+
====
20+
Creating a volume snapshot of a PVC that is in use by a pod can cause unwritten data and cached data to be excluded from the snapshot. To ensure that all data is written to the disk, delete the pod that is using the PVC before creating the snapshot.
21+
====
22+
23+
.Procedure
24+
. Create a file with the `VolumeSnapshotClass` object described by the following YAML:
25+
+
26+
.Example volumesnapshotclass.yaml
27+
[source,yaml]
28+
----
29+
apiVersion: snapshot.storage.k8s.io/v1
30+
kind: VolumeSnapshotClass
31+
metadata:
32+
name: csi-hostpath-snap
33+
driver: hostpath.csi.k8s.io
34+
deletionPolicy: Delete
35+
----
36+
+
37+
`driver` is the name of the CSI driver that is used to create snapshots of this `VolumeSnapshotClass` object. The name must be the same as the `Provisioner` field of the storage class that is responsible for the PVC that is being snapshotted.
38+
+
39+
[NOTE]
40+
====
41+
Depending on the driver that you used to configure persistent storage, additional parameters might be required. You can also use an existing `VolumeSnapshotClass` object.
42+
====
43+
44+
. Create the object you saved in the previous step by entering the following command:
45+
+
46+
[source,terminal]
47+
----
48+
$ oc create -f volumesnapshotclass.yaml
49+
----
50+
51+
. Provide a value for the `volumeSnapshotContentName` parameter as the source for the snapshot:
52+
+
53+
.Example volumesnapshot-manual.yaml
54+
[source,yaml]
55+
----
56+
apiVersion: snapshot.storage.k8s.io/v1
57+
kind: VolumeSnapshot
58+
metadata:
59+
name: snapshot-demo
60+
spec:
61+
source:
62+
volumeSnapshotContentName: mycontent
63+
----
64+
+
65+
`spec.source.volumeSnapshotContentName` is required for pre-provisioned snapshots.
66+
67+
. Create the object you saved in the previous step by entering the following command:
68+
+
69+
[source,terminal]
70+
----
71+
$ oc create -f volumesnapshot-manual.yaml
72+
----
73+
74+
.Verification
75+
After the snapshot has been created in the cluster, additional details about the snapshot are available.
76+
77+
. To display details about the volume snapshot that was created, enter the following command:
78+
+
79+
[source,terminal]
80+
----
81+
$ oc describe volumesnapshot mysnap
82+
----
83+
+
84+
The following example displays details about the `mysnap` volume snapshot:
85+
+
86+
.Example volumesnapshot.yaml
87+
[source,yaml]
88+
----
89+
apiVersion: snapshot.storage.k8s.io/v1
90+
kind: VolumeSnapshot
91+
metadata:
92+
name: mysnap
93+
spec:
94+
source:
95+
persistentVolumeClaimName: myclaim
96+
volumeSnapshotClassName: csi-hostpath-snap
97+
status:
98+
boundVolumeSnapshotContentName: snapcontent-1af4989e-a365-4286-96f8-d5dcd65d78d6
99+
creationTime: "2020-01-29T12:24:30Z"
100+
readyToUse: true
101+
restoreSize: 500Mi
102+
----
103+
+
104+
* `status.boundVolumeSnapshotContentName`: Specifies the pointer to the actual storage content that was created by the controller.
105+
* `status.creationTime`: Specifies the time when the snapshot was created. The snapshot contains the volume content that was available at this indicated time.
106+
* `status.readyToUse`: If the value is set to `true`, the snapshot can be used to restore as a new PVC. If the value is set to `false`, the snapshot was created. However, the storage back end needs to perform additional tasks to make the snapshot usable so that it can be restored as a new volume. For example, Amazon Elastic Block Store data might be moved to a different, less expensive location, which can take several minutes.
107+
108+
. To verify that the volume snapshot was created, enter the following command:
109+
+
110+
[source,terminal]
111+
----
112+
$ oc get volumesnapshotcontent
113+
----
114+
+
115+
The pointer to the actual content is displayed. If the `boundVolumeSnapshotContentName` field is populated, a `VolumeSnapshotContent` object exists and the snapshot was created.
116+
117+
. To verify that the snapshot is ready, confirm that the `VolumeSnapshot` object has `readyToUse: true`.

modules/persistent-storage-csi-snapshots-create.adoc

Lines changed: 24 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
:_mod-docs-content-type: PROCEDURE
66
[id="persistent-storage-csi-snapshots-create_{context}"]
7-
= Creating a volume snapshot
7+
= Dynamically creating a volume snapshot
88

9-
When you create a `VolumeSnapshot` object, {product-title} creates a volume snapshot.
9+
[role="_abstract"]
10+
To create a point-in-time backup of a persistent volume claim (PVC), dynamically provision a volume snapshot by defining a VolumeSnapshotClass and VolumeSnapshot that automate the snapshot creation.
1011

12+
When you create a `VolumeSnapshot` object, {product-title} creates a volume snapshot.
1113

1214
.Prerequisites
1315
* Logged in to a running {product-title} cluster.
@@ -21,24 +23,20 @@ Creating a volume snapshot of a PVC that is in use by a pod can cause unwritten
2123
====
2224
2325
.Procedure
24-
25-
To dynamically create a volume snapshot:
26-
2726
. Create a file with the `VolumeSnapshotClass` object described by the following YAML:
28-
2927
+
30-
.volumesnapshotclass.yaml
28+
.Example volumesnapshotclass.yaml
3129
[source,yaml]
3230
----
3331
apiVersion: snapshot.storage.k8s.io/v1
3432
kind: VolumeSnapshotClass
3533
metadata:
3634
name: csi-hostpath-snap
37-
driver: hostpath.csi.k8s.io <1>
35+
driver: hostpath.csi.k8s.io
3836
deletionPolicy: Delete
3937
----
4038
+
41-
<1> The name of the CSI driver that is used to create snapshots of this `VolumeSnapshotClass` object. The name must be the same as the `Provisioner` field of the storage class that is responsible for the PVC that is being snapshotted.
39+
`driver` is the name of the CSI driver that is used to create snapshots of this `VolumeSnapshotClass` object. The name must be the same as the `Provisioner` field of the storage class that is responsible for the PVC that is being snapshotted.
4240
+
4341
[NOTE]
4442
====
@@ -53,24 +51,22 @@ $ oc create -f volumesnapshotclass.yaml
5351
----
5452

5553
. Create a `VolumeSnapshot` object:
56-
5754
+
58-
.volumesnapshot-dynamic.yaml
55+
.Example volumesnapshot-dynamic.yaml
5956
[source,yaml]
6057
----
6158
apiVersion: snapshot.storage.k8s.io/v1
6259
kind: VolumeSnapshot
6360
metadata:
6461
name: mysnap
6562
spec:
66-
volumeSnapshotClassName: csi-hostpath-snap <1>
63+
volumeSnapshotClassName: csi-hostpath-snap
6764
source:
68-
persistentVolumeClaimName: myclaim <2>
65+
persistentVolumeClaimName: myclaim
6966
----
7067
+
71-
<1> The request for a particular class by the volume snapshot. If the `volumeSnapshotClassName` setting is absent and there is a default volume snapshot class, a snapshot is created with the default volume snapshot class name. But if the field is absent and no default volume snapshot class exists, then no snapshot is created.
72-
+
73-
<2> The name of the `PersistentVolumeClaim` object bound to a persistent volume. This defines what you want to create a snapshot of. Required for dynamically provisioning a snapshot.
68+
* `spec.volumeSnapshotClassName`: Specifies the request for a particular class by the volume snapshot. If the `volumeSnapshotClassName` setting is absent and there is a default volume snapshot class, a snapshot is created with the default volume snapshot class name. But if the field is absent and no default volume snapshot class exists, then no snapshot is created.
69+
* `spec.source.persistentVolumeClaimName`: Specifies the name of the `PersistentVolumeClaim` object bound to a persistent volume. This defines what you want to create a snapshot of. Required for dynamically provisioning a snapshot.
7470
7571
. Create the object you saved in the previous step by entering the following command:
7672
+
@@ -79,35 +75,10 @@ spec:
7975
$ oc create -f volumesnapshot-dynamic.yaml
8076
----
8177

82-
83-
To manually provision a snapshot:
84-
85-
. Provide a value for the `volumeSnapshotContentName` parameter as the source for the snapshot, in addition to defining volume snapshot class as shown above.
86-
+
87-
.volumesnapshot-manual.yaml
88-
[source,yaml]
89-
----
90-
apiVersion: snapshot.storage.k8s.io/v1
91-
kind: VolumeSnapshot
92-
metadata:
93-
name: snapshot-demo
94-
spec:
95-
source:
96-
volumeSnapshotContentName: mycontent <1>
97-
----
98-
<1> The `volumeSnapshotContentName` parameter is required for pre-provisioned snapshots.
99-
100-
. Create the object you saved in the previous step by entering the following command:
101-
+
102-
[source,terminal]
103-
----
104-
$ oc create -f volumesnapshot-manual.yaml
105-
----
106-
10778
.Verification
108-
After the snapshot has been created in the cluster, additional details about the snapshot are available.
109-
110-
. To display details about the volume snapshot that was created, enter the following command:
79+
. After the snapshot has been created in the cluster, additional details about the snapshot are available.
80+
+
81+
To display details about the volume snapshot that was created, run the following command:
11182
+
11283
[source,terminal]
11384
----
@@ -116,7 +87,7 @@ $ oc describe volumesnapshot mysnap
11687
+
11788
The following example displays details about the `mysnap` volume snapshot:
11889
+
119-
.volumesnapshot.yaml
90+
.Example volumesnapshot.yaml
12091
[source,yaml]
12192
----
12293
apiVersion: snapshot.storage.k8s.io/v1
@@ -128,16 +99,15 @@ spec:
12899
persistentVolumeClaimName: myclaim
129100
volumeSnapshotClassName: csi-hostpath-snap
130101
status:
131-
boundVolumeSnapshotContentName: snapcontent-1af4989e-a365-4286-96f8-d5dcd65d78d6 <1>
132-
creationTime: "2020-01-29T12:24:30Z" <2>
133-
readyToUse: true <3>
102+
boundVolumeSnapshotContentName: snapcontent-1af4989e-a365-4286-96f8-d5dcd65d78d6
103+
creationTime: "2020-01-29T12:24:30Z"
104+
readyToUse: true
134105
restoreSize: 500Mi
135106
----
136-
<1> The pointer to the actual storage content that was created by the controller.
137-
<2> The time when the snapshot was created. The snapshot contains the volume content that was available at this indicated time.
138-
<3> If the value is set to `true`, the snapshot can be used to restore as a new PVC.
139-
+
140-
If the value is set to `false`, the snapshot was created. However, the storage back end needs to perform additional tasks to make the snapshot usable so that it can be restored as a new volume. For example, Amazon Elastic Block Store data might be moved to a different, less expensive location, which can take several minutes.
107+
+
108+
* `status.boundVolumeSnapshotContentName`: This parameter is the pointer to the actual storage content that was created by the controller.
109+
* `status.creationTime`: Specifies the time when the snapshot was created. The snapshot contains the volume content that was available at this indicated time.
110+
* `status.readyToUse`: Specifies the readiness of the snapshot. If the value is set to `true`, the snapshot can be used to restore as a new PVC. If the value is set to `false`, the snapshot was created. However, the storage back end needs to perform additional tasks to make the snapshot usable so that it can be restored as a new volume. For example, Amazon Elastic Block Store data might be moved to a different, less expensive location, which can take several minutes.
141111
142112
. To verify that the volume snapshot was created, enter the following command:
143113
+
@@ -148,4 +118,4 @@ $ oc get volumesnapshotcontent
148118
+
149119
The pointer to the actual content is displayed. If the `boundVolumeSnapshotContentName` field is populated, a `VolumeSnapshotContent` object exists and the snapshot was created.
150120

151-
. To verify that the snapshot is ready, confirm that the `VolumeSnapshot` object has `readyToUse: true`.
121+
. To verify that the snapshot is ready, confirm that the `VolumeSnapshot` object has `readyToUse: true`.

modules/persistent-storage-csi-snapshots-delete.adoc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
= Deleting a volume snapshot
99

1010
[role="_abstract"]
11-
You can configure how {product-title} deletes volume snapshots.
11+
To clean up unneeded snapshots and free storage resources, delete volume snapshots by setting a deletion policy that controls whether the underlying content is retained or removed.
1212

1313
.Procedure
14-
1514
. Specify the deletion policy that you require in the `VolumeSnapshotClass` object, as shown in the following example:
1615
+
1716
.Example volumesnapshotclass.yaml file
@@ -25,7 +24,8 @@ driver: hostpath.csi.k8s.io
2524
deletionPolicy: Delete
2625
# ...
2726
----
28-
** `deletionPolicy`: When deleting the volume snapshot, if the `Delete` value is set, the underlying snapshot is deleted along with the `VolumeSnapshotContent` object. If the `Retain` value is set, both the underlying snapshot and `VolumeSnapshotContent` object remain.
27+
+
28+
When deleting the volume snapshot, if `deletionPolicy` is set to `Delete`, the underlying snapshot is deleted along with the `VolumeSnapshotContent` object. If the `Retain` value is set, both the underlying snapshot and `VolumeSnapshotContent` object remain.
2929
+
3030
[NOTE]
3131
====
@@ -36,9 +36,10 @@ If the `Retain` value is set and the `VolumeSnapshot` object is deleted without
3636
+
3737
[source,terminal]
3838
----
39-
$ oc delete volumesnapshot _<volumesnapshot_name>_
39+
$ oc delete volumesnapshot <volumesnapshot_name>
4040
----
41-
** Replace `_<volumesnapshot_name>_` with the name of the volume snapshot you want to delete.
41+
+
42+
Replace `<volumesnapshot_name>` with the name of the volume snapshot you want to delete.
4243
+
4344
.Example output
4445
[source,terminal]
@@ -50,9 +51,10 @@ volumesnapshot.snapshot.storage.k8s.io "mysnapshot" deleted
5051
+
5152
[source,terminal]
5253
----
53-
$ oc delete volumesnapshotcontent _<volumesnapshotcontent_name>_
54+
$ oc delete volumesnapshotcontent <volumesnapshotcontent_name>
5455
----
55-
** Replace `_<volumesnapshotcontent_name>_` with the content you want to delete.
56+
+
57+
Replace `<volumesnapshotcontent_name>` with the content you want to delete.
5658

5759
. Optional: If the `VolumeSnapshot` object is not successfully deleted, enter the following command to remove any finalizers for the leftover resource so that the delete operation can continue:
5860
+

modules/persistent-storage-csi-snapshots-operator.adoc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66
[id="persistent-storage-csi-snapshots-operator_{context}"]
77
= About the CSI Snapshot Controller Operator
88

9+
[role="_abstract"]
10+
You can manage volume snapshots in {product-title} by using the CSI Snapshot Controller Operator's custom resource definitions (CRDs) for snapshot requests, storage, and configuration.
11+
912
The Container Storage Interface (CSI) Snapshot Controller Operator runs in the `openshift-cluster-storage-operator` namespace. It is installed by the Cluster Version Operator (CVO) in all clusters by default.
1013

1114
The CSI Snapshot Controller Operator installs the CSI snapshot controller, which runs in the `openshift-cluster-storage-operator` namespace.
1215

1316
== Volume snapshot CRDs
14-
1517
During {product-title} installation, the CSI Snapshot Controller Operator creates the following snapshot custom resource definitions (CRDs) in the `snapshot.storage.k8s.io/v1` API group:
1618

1719
`VolumeSnapshotContent`::
18-
1920
A snapshot taken of a volume in the cluster that has been provisioned by a cluster administrator.
2021
+
2122
Similar to the `PersistentVolume` object, the `VolumeSnapshotContent` CRD is a cluster resource that points to a real snapshot in the storage back end.
@@ -25,13 +26,11 @@ For manually pre-provisioned snapshots, a cluster administrator creates a number
2526
The `VolumeSnapshotContent` CRD is not namespaced and is for use by a cluster administrator.
2627

2728
`VolumeSnapshot`::
28-
2929
Similar to the `PersistentVolumeClaim` object, the `VolumeSnapshot` CRD defines a developer request for a snapshot. The CSI Snapshot Controller Operator runs the CSI snapshot controller, which handles the binding of a `VolumeSnapshot` CRD with an appropriate `VolumeSnapshotContent` CRD. The binding is a one-to-one mapping.
3030
+
3131
The `VolumeSnapshot` CRD is namespaced. A developer uses the CRD as a distinct request for a snapshot.
3232

3333
`VolumeSnapshotClass`::
34-
3534
The `VolumeSnapshotClass` CRD allows a cluster administrator to specify different attributes belonging to a `VolumeSnapshot` object. These attributes may differ among snapshots taken of the same volume on the storage system, in which case they would not be expressed by using the same storage class of a persistent volume claim.
3635
+
3736
The `VolumeSnapshotClass` CRD defines the parameters for the `csi-external-snapshotter` sidecar to use when creating a snapshot. This allows the storage back end to know what kind of snapshot to dynamically create if multiple options are supported.
@@ -48,7 +47,7 @@ If you want to use the images volume snapshot class for dynamic snapshot provisi
4847

4948
* When creating the snapshot object, be sure to set `volumeSnapshotClassName` to `csi-gce-pd-vsc-images`.
5049
+
51-
For information about creating volume snapshots, see Section _Creating a volume snapshot_.
50+
For information about creating volume snapshots, see "Dynamically creating a volume snapshot" and "Statically creating a volume snapshot".
5251
+
5352
.Example images volume snapshot class YAML file
5453
[source,yaml]
@@ -62,6 +61,5 @@ parameters:
6261
snapshot-type: images
6362
----
6463
+
65-
* `metadata.name:csi-gce-pd-vsc-images`: Name for the non-default images volume snapshot class.
66-
64+
* `metadata.name:csi-gce-pd-vsc-images`: Specifies the name for the non-default images volume snapshot class.
6765
* `parameters: snapshot-type: images`: Defines the snapshot as a "golden image" or a bootable template, rather than the standard disk backup.

0 commit comments

Comments
 (0)