From ec2990dafe6d6d5362eab38c56f2f15dbea1f6e6 Mon Sep 17 00:00:00 2001 From: xing-yang Date: Sun, 27 Oct 2019 16:41:31 +0000 Subject: [PATCH] Add documentation for VolumeSnapshot Beta --- .../storage/volume-snapshot-classes.md | 23 ++-- .../docs/concepts/storage/volume-snapshots.md | 106 +++++++++--------- .../feature-gates.md | 3 +- 3 files changed, 72 insertions(+), 60 deletions(-) diff --git a/content/en/docs/concepts/storage/volume-snapshot-classes.md b/content/en/docs/concepts/storage/volume-snapshot-classes.md index fcc16d4ef3329..dcb9516519973 100644 --- a/content/en/docs/concepts/storage/volume-snapshot-classes.md +++ b/content/en/docs/concepts/storage/volume-snapshot-classes.md @@ -1,9 +1,11 @@ --- reviewers: -- jsafrane - saad-ali - thockin - msau42 +- jingxu97 +- xing-yang +- yuxiangqian title: Volume Snapshot Classes content_template: templates/concept weight: 30 @@ -28,7 +30,7 @@ way to describe the "classes" of storage when provisioning a volume snapshot. ## The VolumeSnapshotClass Resource -Each `VolumeSnapshotClass` contains the fields `snapshotter` and `parameters`, +Each `VolumeSnapshotClass` contains the fields `driver`, `deletionPolicy`, and `parameters`, which are used when a `VolumeSnapshot` belonging to the class needs to be dynamically provisioned. @@ -41,23 +43,30 @@ Administrators can specify a default `VolumeSnapshotClass` just for VolumeSnapsh that don't request any particular class to bind to. ```yaml -apiVersion: snapshot.storage.k8s.io/v1alpha1 +apiVersion: snapshot.storage.k8s.io/v1beta1 kind: VolumeSnapshotClass metadata: name: csi-hostpath-snapclass -snapshotter: csi-hostpath +driver: hostpath.csi.k8s.io +deletionPolicy: Delete parameters: ``` -### Snapshotter +### Driver -Volume snapshot classes have a snapshotter that determines what CSI volume plugin is +Volume snapshot classes have a driver that determines what CSI volume plugin is used for provisioning VolumeSnapshots. This field must be specified. +### DeletionPolicy + +Volume snapshot classes have a deletionPolicy. It enables you to configure what happens to a `VolumeSnapshotContent` when the `VolumeSnapshot` object it is bound to is to be deleted. The deletionPolicy of a volume snapshot can either be `Retain` or `Delete`. This field must be specified. + +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. + ## Parameters Volume snapshot classes have parameters that describe volume snapshots belonging to the volume snapshot class. Different parameters may be accepted depending on the -`snapshotter`. +`driver`. {{% /capture %}} diff --git a/content/en/docs/concepts/storage/volume-snapshots.md b/content/en/docs/concepts/storage/volume-snapshots.md index 8470a251062c0..c561be9160c1d 100644 --- a/content/en/docs/concepts/storage/volume-snapshots.md +++ b/content/en/docs/concepts/storage/volume-snapshots.md @@ -1,9 +1,11 @@ --- reviewers: -- jsafrane - saad-ali - thockin - msau42 +- jingxu97 +- xing-yang +- yuxiangqian title: Volume Snapshots content_template: templates/concept weight: 20 @@ -11,8 +13,8 @@ weight: 20 {{% capture overview %}} -{{< feature-state for_k8s_version="v1.12" state="alpha" >}} -This document describes the current state of `VolumeSnapshots` in Kubernetes. Familiarity with [persistent volumes](/docs/concepts/storage/persistent-volumes/) is suggested. +{{< feature-state for_k8s_version="1.17" state="beta" >}} +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/). {{% /capture %}} @@ -27,18 +29,15 @@ A `VolumeSnapshotContent` is a snapshot taken from a volume in the cluster that A `VolumeSnapshot` is a request for snapshot of a volume by a user. It is similar to a PersistentVolumeClaim. -While `VolumeSnapshots` allow a user to consume abstract storage resources, cluster administrators -need to be able to offer a variety of `VolumeSnapshotContents` without exposing -users to the details of how those volume snapshots should be provisioned. For these needs -there is the `VolumeSnapshotClass` resource. +`VolumeSnapshotClass` allows you to specify different attributes belonging to a `VolumeSnapshot`. These attibutes 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`. Users need to be aware of the following when using this feature: -* API Objects `VolumeSnapshot`, `VolumeSnapshotContent`, and `VolumeSnapshotClass` are CRDs, not part of the core API. +* API Objects `VolumeSnapshot`, `VolumeSnapshotContent`, and `VolumeSnapshotClass` are {{< glossary_tooltip term_id="CustomResourceDefinition" text="CRDs" >}}, not part of the core API. * `VolumeSnapshot` support is only available for CSI drivers. -* As part of the deployment process, the Kubernetes team provides a sidecar helper container for the snapshot controller called `external-snapshotter`. It watches `VolumeSnapshot` objects and triggers `CreateSnapshot` and `DeleteSnapshot` operations against a CSI endpoint. -* 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 `external-snapshotter`. -* The CSI drivers that support volume snapshot will automatically install CRDs defined for the volume snapshots. +* As part of the deployment process in the beta version 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 in dynamic provisioning. The sidecar csi-snapshotter watches `VolumeSnapshotContent` objects and triggers `CreateSnapshot` and `DeleteSnapshot` operations against a CSI endpoint. +* 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. +* The CRDs and snapshot controller installations are the responsibility of the Kubernetes distribution. ## Lifecycle of a volume snapshot and volume snapshot content @@ -46,89 +45,92 @@ Users need to be aware of the following when using this feature: ### Provisioning Volume Snapshot -There are two ways snapshots may be provisioned: statically or dynamically. +There are two ways snapshots may be provisioned: pre-provisioned or dynamically provisioned. -#### Static -A cluster administrator creates a number of `VolumeSnapshotContents`. They carry the details of the real storage which is available for use by cluster users. They exist in the Kubernetes API and are available for consumption. +#### Pre-provisioned {#static} +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. #### Dynamic -When none of the static `VolumeSnapshotContents` the administrator created matches a user's `VolumeSnapshot`, -the cluster may try to dynamically provision a volume snapshot specially for the `VolumeSnapshot` object. -This provisioning is based on `VolumeSnapshotClasses`: the `VolumeSnapshot` must request a -[volume snapshot class](/docs/concepts/storage/volume-snapshot-classes/) and -the administrator must have created and configured that class in order for dynamic -provisioning to occur. +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. ### Binding -A user creates, or has already created in the case of dynamic provisioning, a `VolumeSnapshot` with a specific amount of storage requested and with certain access modes. A control loop watches for new VolumeSnapshots, finds a matching VolumeSnapshotContent (if possible), and binds them together. If a VolumeSnapshotContent was dynamically provisioned for a new VolumeSnapshot, the loop will always bind that VolumeSnapshotContent to the VolumeSnapshot. Once bound, `VolumeSnapshot` binds are exclusive, regardless of how they were bound. A VolumeSnapshot to VolumeSnapshotContent binding is a one-to-one mapping. +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. VolumeSnapshots will remain unbound indefinitely if a matching VolumeSnapshotContent does not exist. VolumeSnapshots will be bound as matching VolumeSnapshotContents become available. -### Persistent Volume Claim in Use Protection +### Persistent Volume Claim as Snapshot Source Protection -The purpose of the Persistent Volume Claim Object in Use Protection feature is to ensure that in-use PVC API objects are not removed from the system (as this may result in data loss). +The purpose of this protection is to ensure that in-use PersistentVolumeClaim API objects are not removed from the system (as this may result in data loss). -If a PVC is in active use by a snapshot as a source to create the snapshot, the PVC is in-use. If a user deletes a PVC API object in active use as a snapshot source, the PVC object is not removed immediately. Instead, removal of the PVC object is postponed until the PVC is no longer actively used by any snapshots. A PVC is no longer used as a snapshot source when `ReadyToUse` of the snapshot `Status` becomes `true`. +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. ### Delete -Deletion removes both the `VolumeSnapshotContent` object from the Kubernetes API, as well as the associated storage asset in the external infrastructure. +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. ## Volume Snapshot Contents -Each VolumeSnapshotContent contains a spec, which is the specification of the volume snapshot. +Each VolumeSnapshotContent contains a spec and status. In dynamic provisioning, the snapshot common controller creates `VolumeSnapshotContent` objects. Here is an example: ```yaml -apiVersion: snapshot.storage.k8s.io/v1alpha1 +apiVersion: snapshot.storage.k8s.io/v1beta1 kind: VolumeSnapshotContent metadata: - name: new-snapshot-content-test + name: snapcontent-72d9a349-aacd-42d2-a240-d775650d2455 spec: - snapshotClassName: csi-hostpath-snapclass + deletionPolicy: Delete + driver: hostpath.csi.k8s.io source: - name: pvc-test - kind: PersistentVolumeClaim - volumeSnapshotSource: - csiVolumeSnapshotSource: - creationTime: 1535478900692119403 - driver: csi-hostpath - restoreSize: 10Gi - snapshotHandle: 7bdd0de3-aaeb-11e8-9aae-0242ac110002 + volumeHandle: ee0cfb94-f8d4-11e9-b2d8-0242ac110002 + volumeSnapshotClassName: csi-hostpath-snapclass + volumeSnapshotRef: + name: new-snapshot-test + namespace: default + uid: 72d9a349-aacd-42d2-a240-d775650d2455 ``` -### Class +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. + +For pre-provisioned snapshots, you (as cluster administrator) are responsible for creating the `VolumeSnapshotContent` object as follows. + +```yaml +apiVersion: snapshot.storage.k8s.io/v1beta1 +kind: VolumeSnapshotContent +metadata: + name: new-snapshot-content-test +spec: + deletionPolicy: Delete + driver: hostpath.csi.k8s.io + source: + snapshotHandle: 7bdd0de3-aaeb-11e8-9aae-0242ac110002 + volumeSnapshotRef: + name: new-snapshot-test + namespace: default +``` -A VolumeSnapshotContent can have a class, which is specified by setting the -`snapshotClassName` attribute to the name of a -[VolumeSnapshotClass](/docs/concepts/storage/volume-snapshot-classes/). -A VolumeSnapshotContent of a particular class can only be bound to VolumeSnapshots requesting -that class. A VolumeSnapshotContent with no `snapshotClassName` has no class and can only be bound -to VolumeSnapshots that request no particular class. +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 physical volume snapshot resource on the storage system that this `VolumeSnapshotContent` represents. ## VolumeSnapshots -Each VolumeSnapshot contains a spec and a status, which is the specification and status of the volume snapshot. +Each VolumeSnapshot contains a spec and a status. ```yaml -apiVersion: snapshot.storage.k8s.io/v1alpha1 +apiVersion: snapshot.storage.k8s.io/v1beta1 kind: VolumeSnapshot metadata: name: new-snapshot-test spec: - snapshotClassName: csi-hostpath-snapclass + volumeSnapshotClassName: csi-hostpath-snapclass source: - name: pvc-test - kind: PersistentVolumeClaim + persistentVolumeClaimName: pvc-test ``` ### Class A volume snapshot can request a particular class by specifying the name of a [VolumeSnapshotClass](/docs/concepts/storage/volume-snapshot-classes/) -using the attribute `snapshotClassName`. -Only VolumeSnapshotContents of the requested class, ones with the same `snapshotClassName` -as the VolumeSnapshot, can be bound to the VolumeSnapshot. +using the attribute `volumeSnapshotClassName`. If nothing is set, then the default class is used if available. ## Provisioning Volumes from Snapshots diff --git a/content/en/docs/reference/command-line-tools-reference/feature-gates.md b/content/en/docs/reference/command-line-tools-reference/feature-gates.md index 777941f8c9819..7591506e73785 100644 --- a/content/en/docs/reference/command-line-tools-reference/feature-gates.md +++ b/content/en/docs/reference/command-line-tools-reference/feature-gates.md @@ -150,7 +150,8 @@ different Kubernetes components. | `VolumePVCDataSource` | `true` | Beta | 1.16 | | | `VolumeSubpathEnvExpansion` | `false` | Alpha | 1.14 | 1.14 | | `VolumeSubpathEnvExpansion` | `true` | Beta | 1.15 | | -| `VolumeSnapshotDataSource` | `false` | Alpha | 1.12 | - | +| `VolumeSnapshotDataSource` | `false` | Alpha | 1.12 | 1.16 | +| `VolumeSnapshotDataSource` | `true` | Beta | 1.17 | - | | `WindowsGMSA` | `false` | Alpha | 1.14 | | | `WindowsGMSA` | `true` | Beta | 1.16 | | | `WinDSR` | `false` | Alpha | 1.14 | |