Skip to content

Commit f89729d

Browse files
committed
Add docs for preventing volume mode conversion
1 parent 1bf1d8b commit f89729d

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

content/en/docs/concepts/storage/volume-snapshots.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ spec:
120120
driver: hostpath.csi.k8s.io
121121
source:
122122
volumeHandle: ee0cfb94-f8d4-11e9-b2d8-0242ac110002
123+
sourceVolumeMode: Filesystem
123124
volumeSnapshotClassName: csi-hostpath-snapclass
124125
volumeSnapshotRef:
125126
name: new-snapshot-test
@@ -141,13 +142,44 @@ spec:
141142
driver: hostpath.csi.k8s.io
142143
source:
143144
snapshotHandle: 7bdd0de3-aaeb-11e8-9aae-0242ac110002
145+
sourceVolumeMode: Filesystem
144146
volumeSnapshotRef:
145147
name: new-snapshot-test
146148
namespace: default
147149
```
148150

149151
`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.
150152

153+
`sourceVolumeMode` is the mode of the volume whose snapshot is taken. The value of the `sourceVolumeMode` field can be either `Filesystem` or `Block`. If the source volume mode is not specified, Kubernetes treats the snapshot as if the source volume's mode is unknown. Support for this field can only be enabled in VolumeSnapshot client v6.0.0 and higher. Visit the [VolumeSnapshot Release page](https://github.com/kubernetes-csi/external-snapshotter/releases) for more information.
154+
155+
## Converting the volume mode of a Snapshot {#convert-volume-mode}
156+
157+
This feature is only present for `VolumeSnapshotContents` created with client version `v6.0.0` onwards.
158+
The volume mode can be either `Filesystem` or `Block`. If not specified, it indicates the volume mode is unknown.
159+
If you want to allow users to create a `PersistentVolumeClaim` from an existing `VolumeSnapshot`, but with a
160+
different volume mode than the source, the annotation `snapshot.storage.kubernetes.io/allowVolumeModeChange: "true"`
161+
needs to be added to the `VolumeSnapshotContent` that corresponds to the `VolumeSnapshot`. For pre-provisioned snapshots,
162+
`Spec.SourceVolumeMode` needs to be populated by the cluster administrator.
163+
An example `VolumeSnapshotContent` resource with this feature enabled would look like:
164+
165+
```yaml
166+
apiVersion: snapshot.storage.k8s.io/v1
167+
kind: VolumeSnapshotContent
168+
metadata:
169+
name: new-snapshot-content-test
170+
annotations:
171+
- snapshot.storage.kubernetes.io/allowVolumeModeChange: "true"
172+
spec:
173+
deletionPolicy: Delete
174+
driver: hostpath.csi.k8s.io
175+
source:
176+
snapshotHandle: 7bdd0de3-aaeb-11e8-9aae-0242ac110002
177+
sourceVolumeMode: Filesystem
178+
volumeSnapshotRef:
179+
name: new-snapshot-test
180+
namespace: default
181+
```
182+
151183
## Provisioning Volumes from Snapshots
152184

153185
You can provision a new volume, pre-populated with data from a snapshot, by using

content/en/docs/reference/labels-annotations-taints/_index.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,18 @@ you through the steps you follow to apply a seccomp profile to a Pod or to one o
508508
its containers. That tutorial covers the supported mechanism for configuring seccomp in Kubernetes,
509509
based on setting `securityContext` within the Pod's `.spec`.
510510

511+
### snapshot.storage.kubernetes.io/allowVolumeModeChange
512+
513+
Example: `snapshot.storage.kubernetes.io/allowVolumeModeChange: true`
514+
515+
Used on: VolumeSnapshotContent
516+
517+
Value can either be `true` or `false`.
518+
This determines whether a user can modify the mode of the source volume when a `PVC` is being created from a `VolumeSnapshot`.
519+
520+
See [Converting the volume mode of a Snapshot](/docs/concepts/storage/volume-snapshots/#convert-volume-mode) for more information.
521+
522+
511523
## Annotations used for audit
512524

513525
<!-- sorted by annotation -->

0 commit comments

Comments
 (0)