-
Notifications
You must be signed in to change notification settings - Fork 807
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
124 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Dynamic Volume Provisioning with AWS EBS CSI Driver | ||
|
||
## Prerequisites | ||
|
||
1. Kubernetes 1.13+ (CSI 1.0). | ||
|
||
1. The [aws-ebs-csi-driver driver](https://github.com/kubernetes-sigs/aws-ebs-csi-driver) is installed. | ||
|
||
## Usage | ||
|
||
1. Create a sample app along with the StorageClass and the PersistentVolumeClaim: | ||
``` | ||
kubectl apply -f specs/ | ||
``` | ||
|
||
2. Validate the volume was created and `volumeHandle` contains an EBS volumeID: | ||
``` | ||
kubectl describe pv | ||
``` | ||
|
||
3. Validate the pod successfully wrote data to the volume: | ||
``` | ||
kubectl exec -it app cat /data/out.txt | ||
``` | ||
|
||
4. Cleanup resources: | ||
``` | ||
kubectl delete -f specs/ | ||
``` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,67 @@ | ||
# Volume Snapshots with AWS EBS CSI Driver | ||
# Volume Snapshots | ||
|
||
## Overview | ||
|
||
This driver implements basic volume snapshotting functionality, i.e. it is possible to use it along with the [external | ||
snapshotter](https://github.com/kubernetes-csi/external-snapshotter) sidecar and create snapshots of EBS volumes using | ||
the `VolumeSnapshot` custom resources. | ||
This driver implements basic volume snapshotting functionality using the [external snapshotter](https://github.com/kubernetes-csi/external-snapshotter) sidecar and creates snapshots of EBS volumes using the `VolumeSnapshot` custom resources. | ||
|
||
## Prerequisites | ||
|
||
1. Kubernetes 1.13+ (CSI 1.0) is required | ||
|
||
2. The `VolumeSnapshotDataSource` feature gate of Kubernetes API server and controller manager must be turned on. | ||
|
||
## Usage | ||
|
||
This directory contains example YAML files to test the feature. First, see the [deployment example](../../../deploy/kubernetes) and [volume scheduling example](../volume_scheduling) | ||
to set up the external provisioner: | ||
|
||
### Set up | ||
|
||
1. Create the RBAC rules | ||
|
||
2. Start the contoller `StatefulSet` | ||
|
||
3. Start the node `DaemonSet` | ||
|
||
4. Create a `StorageClass` for dynamic provisioning of the AWS CSI volumes | ||
|
||
5. Create a `SnapshotClass` to create `VolumeSnapshot`s using the AWS CSI external controller | ||
|
||
6. Create a `PersistentVolumeClaim` and a pod using it | ||
|
||
### Taking and restoring volume snapshot | ||
|
||
7. Create a `VolumeSnapshot` referencing the `PersistentVolumeClaim`; the snapshot creation may take time to finish: | ||
check the `ReadyToUse` attribute of the `VolumeSnapshot` object to find out when a new `PersistentVolume` can be | ||
created from the snapshot | ||
|
||
8. To restore a volume from a snapshot use a `PersistentVolumeClaim` referencing the `VolumeSnapshot` in its `dataSource`; see the | ||
[Kubernetes Persistent Volumes documentation](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#volume-snapshot-and-restore-volume-from-snapshot-support) | ||
and the example [restore claim](./restore-claim.yaml) | ||
1. Kubernetes 1.13+ (CSI 1.0). | ||
|
||
1. The `VolumeSnapshotDataSource` must be set in `--feature-gates=` in the `kube-apiserver`. | ||
|
||
1. The [aws-ebs-csi-driver driver](https://github.com/kubernetes-sigs/aws-ebs-csi-driver) is installed. | ||
|
||
### Usage | ||
|
||
1. Create the `StorageClass` and `VolumeSnapshotClass`: | ||
``` | ||
kubectl apply -f specs/classes/ | ||
``` | ||
|
||
2. Create a sample app and the `PersistentVolumeClaim`: | ||
``` | ||
kubectl apply -f specs/app/ | ||
``` | ||
|
||
3. Validate the volume was created and `volumeHandle` contains an EBS volumeID: | ||
``` | ||
kubectl describe pv | ||
``` | ||
|
||
4. Validate the pod successfully wrote data to the volume, taking note of the timestamp of the first entry: | ||
``` | ||
kubectl exec -it app cat /data/out.txt | ||
``` | ||
|
||
5. Create a `VolumeSnapshot` referencing the `PersistentVolumeClaim` name: | ||
``` | ||
kubectl apply -f specs/snapshot/ | ||
``` | ||
|
||
6. Wait for the `Ready To Use: true` attribute of the `VolumeSnapshot`: | ||
``` | ||
kubectl describe volumesnapshot.snapshot.storage.k8s.io ebs-volume-snapshot | ||
``` | ||
|
||
7. Delete the existing app: | ||
``` | ||
kubectl delete -f specs/app/ | ||
``` | ||
|
||
8. Restore a volume from the snapshot with a `PersistentVolumeClaim` referencing the `VolumeSnapshot` in its `dataSource`: | ||
``` | ||
kubectl apply -f specs/snapshot-restore/ | ||
``` | ||
|
||
9. Validate the new pod has the restored data by comparing the timestamp of the first entry to that of in step 4: | ||
``` | ||
kubectl exec -it app cat /data/out.txt | ||
``` | ||
|
||
10. Cleanup resources: | ||
``` | ||
kubectl delete -f specs/snapshot-restore | ||
kubectl delete -f specs/snapshot | ||
kubectl delete -f specs/classes | ||
``` |
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...es/kubernetes/snapshot/snapshotclass.yaml → ...snapshot/specs/classes/snapshotclass.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
apiVersion: snapshot.storage.k8s.io/v1alpha1 | ||
kind: VolumeSnapshotClass | ||
metadata: | ||
name: csi-aws-snapclass | ||
name: csi-aws-vsc | ||
snapshotter: ebs.csi.aws.com |
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...es/kubernetes/snapshot/restore-claim.yaml → ...napshot/specs/snapshot-restore/claim.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
examples/kubernetes/snapshot/specs/snapshot-restore/pod.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: app | ||
spec: | ||
containers: | ||
- name: app | ||
image: centos | ||
command: ["/bin/sh"] | ||
args: ["-c", "while true; do echo $(date -u) >> /data/out.txt; sleep 5; done"] | ||
volumeMounts: | ||
- name: persistent-storage | ||
mountPath: /data | ||
volumes: | ||
- name: persistent-storage | ||
persistentVolumeClaim: | ||
claimName: ebs-snapshot-restored-claim |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
kubeAPIServer: | ||
featureGates: | ||
CSIDriverRegistry: "true" | ||
CSINodeInfo: "true" | ||
CSIBlockVolume: "true" | ||
kubelet: | ||
featureGates: | ||
CSIDriverRegistry: "true" | ||
CSINodeInfo: "true" | ||
CSIBlockVolume: "true" | ||
kubeAPIServer: | ||
featureGates: | ||
CSIDriverRegistry: "true" | ||
CSINodeInfo: "true" | ||
CSIBlockVolume: "true" | ||
kubelet: | ||
featureGates: | ||
CSIDriverRegistry: "true" | ||
CSINodeInfo: "true" | ||
CSIBlockVolume: "true" |