You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/concepts/storage/volume-snapshots.md
+97-41Lines changed: 97 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,65 +13,107 @@ weight: 60
13
13
14
14
<!-- overview -->
15
15
16
-
In Kubernetes, a _VolumeSnapshot_ represents a snapshot of a volume on a storage system. This document assumes that you are already familiar with Kubernetes [persistent volumes](/docs/concepts/storage/persistent-volumes/).
17
-
18
-
19
-
16
+
In Kubernetes, a _VolumeSnapshot_ represents a snapshot of a volume on a storage
17
+
system. This document assumes that you are already familiar with Kubernetes
Similar to how API resources `PersistentVolume` and `PersistentVolumeClaim` are used to provision volumes for users and administrators, `VolumeSnapshotContent` and `VolumeSnapshot` API resources are provided to create volume snapshots for users and administrators.
24
+
Similar to how API resources `PersistentVolume` and `PersistentVolumeClaim` are
25
+
used to provision volumes for users and administrators, `VolumeSnapshotContent`
26
+
and `VolumeSnapshot` API resources are provided to create volume snapshots for
27
+
users and administrators.
26
28
27
-
A `VolumeSnapshotContent` is a snapshot taken from a volume in the cluster that has been provisioned by an administrator. It is a resource in the cluster just like a PersistentVolume is a cluster resource.
29
+
A `VolumeSnapshotContent` is a snapshot taken from a volume in the cluster that
30
+
has been provisioned by an administrator. It is a resource in the cluster just
31
+
like a PersistentVolume is a cluster resource.
28
32
29
-
A `VolumeSnapshot` is a request for snapshot of a volume by a user. It is similar to a PersistentVolumeClaim.
33
+
A `VolumeSnapshot` is a request for snapshot of a volume by a user. It is similar
34
+
to a PersistentVolumeClaim.
30
35
31
-
`VolumeSnapshotClass` allows you to specify different attributes belonging to a `VolumeSnapshot`. These attributes may differ among snapshots taken from the same volume on the storage system and therefore cannot be expressed by using the same `StorageClass` of a `PersistentVolumeClaim`.
36
+
`VolumeSnapshotClass` allows you to specify different attributes belonging to a
37
+
`VolumeSnapshot`. These attributes may differ among snapshots taken from the same
38
+
volume on the storage system and therefore cannot be expressed by using the same
39
+
`StorageClass` of a `PersistentVolumeClaim`.
32
40
33
-
Volume snapshots provide Kubernetes users with a standardized way to copy a volume's contents at a particular point in time without creating an entirely new volume. This functionality enables, for example, database administrators to backup databases before performing edit or delete modifications.
41
+
Volume snapshots provide Kubernetes users with a standardized way to copy a volume's
42
+
contents at a particular point in time without creating an entirely new volume. This
43
+
functionality enables, for example, database administrators to backup databases before
44
+
performing edit or delete modifications.
34
45
35
46
Users need to be aware of the following when using this feature:
36
47
37
-
* API Objects `VolumeSnapshot`, `VolumeSnapshotContent`, and `VolumeSnapshotClass` are {{< glossary_tooltip term_id="CustomResourceDefinition" text="CRDs" >}}, not part of the core API.
38
-
*`VolumeSnapshot` support is only available for CSI drivers.
39
-
* As part of the deployment process of `VolumeSnapshot`, the Kubernetes team provides a snapshot controller to be deployed into the control plane, and a sidecar helper container called csi-snapshotter to be deployed together with the CSI driver. The snapshot controller watches `VolumeSnapshot` and `VolumeSnapshotContent` objects and is responsible for the creation and deletion of `VolumeSnapshotContent` object. The sidecar csi-snapshotter watches `VolumeSnapshotContent` objects and triggers `CreateSnapshot` and `DeleteSnapshot` operations against a CSI endpoint.
40
-
* There is also a validating webhook server which provides tightened validation on snapshot objects. This should be installed by the Kubernetes distros along with the snapshot controller and CRDs, not CSI drivers. It should be installed in all Kubernetes clusters that has the snapshot feature enabled.
41
-
* CSI drivers may or may not have implemented the volume snapshot functionality. The CSI drivers that have provided support for volume snapshot will likely use the csi-snapshotter. See [CSI Driver documentation](https://kubernetes-csi.github.io/docs/) for details.
42
-
* The CRDs and snapshot controller installations are the responsibility of the Kubernetes distribution.
48
+
- API Objects `VolumeSnapshot`, `VolumeSnapshotContent`, and `VolumeSnapshotClass`
49
+
are {{< glossary_tooltip term_id="CustomResourceDefinition" text="CRDs" >}}, not
50
+
part of the core API.
51
+
-`VolumeSnapshot` support is only available for CSI drivers.
52
+
- As part of the deployment process of `VolumeSnapshot`, the Kubernetes team provides
53
+
a snapshot controller to be deployed into the control plane, and a sidecar helper
54
+
container called csi-snapshotter to be deployed together with the CSI driver.
55
+
The snapshot controller watches `VolumeSnapshot` and `VolumeSnapshotContent` objects
56
+
and is responsible for the creation and deletion of `VolumeSnapshotContent` object.
57
+
The sidecar csi-snapshotter watches `VolumeSnapshotContent` objects and triggers
58
+
`CreateSnapshot` and `DeleteSnapshot` operations against a CSI endpoint.
59
+
- There is also a validating webhook server which provides tightened validation on
60
+
snapshot objects. This should be installed by the Kubernetes distros along with
61
+
the snapshot controller and CRDs, not CSI drivers. It should be installed in all
62
+
Kubernetes clusters that has the snapshot feature enabled.
63
+
- CSI drivers may or may not have implemented the volume snapshot functionality.
64
+
The CSI drivers that have provided support for volume snapshot will likely use
65
+
the csi-snapshotter. See [CSI Driver documentation](https://kubernetes-csi.github.io/docs/) for details.
66
+
- The CRDs and snapshot controller installations are the responsibility of the Kubernetes distribution.
43
67
44
68
## Lifecycle of a volume snapshot and volume snapshot content
45
69
46
-
`VolumeSnapshotContents` are resources in the cluster. `VolumeSnapshots` are requests for those resources. The interaction between `VolumeSnapshotContents` and `VolumeSnapshots` follow this lifecycle:
70
+
`VolumeSnapshotContents` are resources in the cluster. `VolumeSnapshots` are requests
71
+
for those resources. The interaction between `VolumeSnapshotContents` and `VolumeSnapshots`
72
+
follow this lifecycle:
47
73
48
74
### Provisioning Volume Snapshot
49
75
50
76
There are two ways snapshots may be provisioned: pre-provisioned or dynamically provisioned.
51
77
52
78
#### Pre-provisioned {#static}
53
-
A cluster administrator creates a number of `VolumeSnapshotContents`. They carry the details of the real volume snapshot on the storage system which is available for use by cluster users. They exist in the Kubernetes API and are available for consumption.
79
+
80
+
A cluster administrator creates a number of `VolumeSnapshotContents`. They carry the details
81
+
of the real volume snapshot on the storage system which is available for use by cluster users.
82
+
They exist in the Kubernetes API and are available for consumption.
54
83
55
84
#### Dynamic
56
-
Instead of using a pre-existing snapshot, you can request that a snapshot to be dynamically taken from a PersistentVolumeClaim. The [VolumeSnapshotClass](/docs/concepts/storage/volume-snapshot-classes/) specifies storage provider-specific parameters to use when taking a snapshot.
85
+
86
+
Instead of using a pre-existing snapshot, you can request that a snapshot to be dynamically
87
+
taken from a PersistentVolumeClaim. The [VolumeSnapshotClass](/docs/concepts/storage/volume-snapshot-classes/)
88
+
specifies storage provider-specific parameters to use when taking a snapshot.
57
89
58
90
### Binding
59
91
60
-
The snapshot controller handles the binding of a `VolumeSnapshot` object with an appropriate `VolumeSnapshotContent` object, in both pre-provisioned and dynamically provisioned scenarios. The binding is a one-to-one mapping.
92
+
The snapshot controller handles the binding of a `VolumeSnapshot` object with an appropriate
93
+
`VolumeSnapshotContent` object, in both pre-provisioned and dynamically provisioned scenarios.
94
+
The binding is a one-to-one mapping.
61
95
62
-
In the case of pre-provisioned binding, the VolumeSnapshot will remain unbound until the requested VolumeSnapshotContent object is created.
96
+
In the case of pre-provisioned binding, the VolumeSnapshot will remain unbound until the
97
+
requested VolumeSnapshotContent object is created.
63
98
64
99
### Persistent Volume Claim as Snapshot Source Protection
65
100
66
101
The purpose of this protection is to ensure that in-use
API objects are not removed from the system while a snapshot is being taken from it (as this may result in data loss).
103
+
API objects are not removed from the system while a snapshot is being taken from it
104
+
(as this may result in data loss).
69
105
70
-
While a snapshot is being taken of a PersistentVolumeClaim, that PersistentVolumeClaim is in-use. If you delete a PersistentVolumeClaim API object in active use as a snapshot source, the PersistentVolumeClaim object is not removed immediately. Instead, removal of the PersistentVolumeClaim object is postponed until the snapshot is readyToUse or aborted.
106
+
While a snapshot is being taken of a PersistentVolumeClaim, that PersistentVolumeClaim
107
+
is in-use. If you delete a PersistentVolumeClaim API object in active use as a snapshot
108
+
source, the PersistentVolumeClaim object is not removed immediately. Instead, removal of
109
+
the PersistentVolumeClaim object is postponed until the snapshot is readyToUse or aborted.
71
110
72
111
### Delete
73
112
74
-
Deletion is triggered by deleting the `VolumeSnapshot` object, and the `DeletionPolicy` will be followed. If the `DeletionPolicy` is `Delete`, then the underlying storage snapshot will be deleted along with the `VolumeSnapshotContent` object. If the `DeletionPolicy` is `Retain`, then both the underlying snapshot and `VolumeSnapshotContent` remain.
113
+
Deletion is triggered by deleting the `VolumeSnapshot` object, and the `DeletionPolicy`
114
+
will be followed. If the `DeletionPolicy` is `Delete`, then the underlying storage snapshot
115
+
will be deleted along with the `VolumeSnapshotContent` object. If the `DeletionPolicy` is
116
+
`Retain`, then both the underlying snapshot and `VolumeSnapshotContent` remain.
75
117
76
118
## VolumeSnapshots
77
119
@@ -88,13 +130,17 @@ spec:
88
130
persistentVolumeClaimName: pvc-test
89
131
```
90
132
91
-
`persistentVolumeClaimName` is the name of the PersistentVolumeClaim data source for the snapshot. This field is required for dynamically provisioning a snapshot.
133
+
`persistentVolumeClaimName` is the name of the PersistentVolumeClaim data source
134
+
for the snapshot. This field is required for dynamically provisioning a snapshot.
92
135
93
136
A volume snapshot can request a particular class by specifying the name of a
using the attribute `volumeSnapshotClassName`. If nothing is set, then the default class is used if available.
138
+
using the attribute `volumeSnapshotClassName`. If nothing is set, then the
139
+
default class is used if available.
96
140
97
-
For pre-provisioned snapshots, you need to specify a `volumeSnapshotContentName` as the source for the snapshot as shown in the following example. The `volumeSnapshotContentName` source field is required for pre-provisioned snapshots.
141
+
For pre-provisioned snapshots, you need to specify a `volumeSnapshotContentName`
142
+
as the source for the snapshot as shown in the following example. The
143
+
`volumeSnapshotContentName`source field is required for pre-provisioned snapshots.
98
144
99
145
```yaml
100
146
apiVersion: snapshot.storage.k8s.io/v1
@@ -108,7 +154,8 @@ spec:
108
154
109
155
## Volume Snapshot Contents
110
156
111
-
Each VolumeSnapshotContent contains a spec and status. In dynamic provisioning, the snapshot common controller creates `VolumeSnapshotContent` objects. Here is an example:
157
+
Each VolumeSnapshotContent contains a spec and status. In dynamic provisioning,
158
+
the snapshot common controller creates `VolumeSnapshotContent` objects. Here is an example:
112
159
113
160
```yaml
114
161
apiVersion: snapshot.storage.k8s.io/v1
@@ -128,9 +175,13 @@ spec:
128
175
uid: 72d9a349-aacd-42d2-a240-d775650d2455
129
176
```
130
177
131
-
`volumeHandle`is the unique identifier of the volume created on the storage backend and returned by the CSI driver during the volume creation. This field is required for dynamically provisioning a snapshot. It specifies the volume source of the snapshot.
178
+
`volumeHandle`is the unique identifier of the volume created on the storage
179
+
backend and returned by the CSI driver during the volume creation. This field
180
+
is required for dynamically provisioning a snapshot.
181
+
It specifies the volume source of the snapshot.
132
182
133
-
For pre-provisioned snapshots, you (as cluster administrator) are responsible for creating the `VolumeSnapshotContent` object as follows.
183
+
For pre-provisioned snapshots, you (as cluster administrator) are responsible
184
+
for creating the `VolumeSnapshotContent` object as follows.
134
185
135
186
```yaml
136
187
apiVersion: snapshot.storage.k8s.io/v1
@@ -148,19 +199,24 @@ spec:
148
199
namespace: default
149
200
```
150
201
151
-
`snapshotHandle`is the unique identifier of the volume snapshot created on the storage backend. This field is required for the pre-provisioned snapshots. It specifies the CSI snapshot id on the storage system that this `VolumeSnapshotContent` represents.
202
+
`snapshotHandle`is the unique identifier of the volume snapshot created on
203
+
the storage backend. This field is required for the pre-provisioned snapshots.
204
+
It specifies the CSI snapshot id on the storage system that this
205
+
`VolumeSnapshotContent`represents.
152
206
153
-
`sourceVolumeMode`is the mode of the volume whose snapshot is taken. The value
154
-
of the `sourceVolumeMode` field can be either `Filesystem` or `Block`. If the
155
-
source volume mode is not specified, Kubernetes treats the snapshot as if the
207
+
`sourceVolumeMode`is the mode of the volume whose snapshot is taken. The value
208
+
of the `sourceVolumeMode` field can be either `Filesystem` or `Block`. If the
209
+
source volume mode is not specified, Kubernetes treats the snapshot as if the
156
210
source volume's mode is unknown.
157
211
158
-
`volumeSnapshotRef`is the reference of the corresponding `VolumeSnapshot`. Note that when the `VolumeSnapshotContent` is being created as a pre-provisioned snapshot, the `VolumeSnapshot` referenced in `volumeSnapshotRef` might not exist yet.
212
+
`volumeSnapshotRef`is the reference of the corresponding `VolumeSnapshot`. Note that
213
+
when the `VolumeSnapshotContent` is being created as a pre-provisioned snapshot, the
214
+
`VolumeSnapshot`referenced in `volumeSnapshotRef` might not exist yet.
159
215
160
216
## Converting the volume mode of a Snapshot {#convert-volume-mode}
161
217
162
218
If the `VolumeSnapshots` API installed on your cluster supports the `sourceVolumeMode`
163
-
field, then the API has the capability to prevent unauthorized users from converting
219
+
field, then the API has the capability to prevent unauthorized users from converting
164
220
the mode of a volume.
165
221
166
222
To check if your cluster has capability for this feature, run the following command:
@@ -169,12 +225,12 @@ To check if your cluster has capability for this feature, run the following comm
169
225
$ kubectl get crd volumesnapshotcontent -o yaml
170
226
```
171
227
172
-
If you want to allow users to create a `PersistentVolumeClaim` from an existing
173
-
`VolumeSnapshot`, but with a different volume mode than the source, the annotation
174
-
`snapshot.storage.kubernetes.io/allowVolumeModeChange: "true"`needs to be added to
175
-
the `VolumeSnapshotContent` that corresponds to the `VolumeSnapshot`.
228
+
If you want to allow users to create a `PersistentVolumeClaim` from an existing
229
+
`VolumeSnapshot`, but with a different volume mode than the source, the annotation
230
+
`snapshot.storage.kubernetes.io/allowVolumeModeChange: "true"`needs to be added to
231
+
the `VolumeSnapshotContent` that corresponds to the `VolumeSnapshot`.
176
232
177
-
For pre-provisioned snapshots, `Spec.SourceVolumeMode` needs to be populated
233
+
For pre-provisioned snapshots, `Spec.SourceVolumeMode` needs to be populated
178
234
by the cluster administrator.
179
235
180
236
An example `VolumeSnapshotContent` resource with this feature enabled would look like:
@@ -200,7 +256,7 @@ spec:
200
256
## Provisioning Volumes from Snapshots
201
257
202
258
You can provision a new volume, pre-populated with data from a snapshot, by using
203
-
the *dataSource* field in the `PersistentVolumeClaim` object.
259
+
the _dataSource_ field in the `PersistentVolumeClaim` object.
204
260
205
261
For more details, see
206
262
[Volume Snapshot and Restore Volume from Snapshot](/docs/concepts/storage/persistent-volumes/#volume-snapshot-and-restore-volume-from-snapshot-support).
0 commit comments