Skip to content

Commit

Permalink
Cleanup README and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoshkin committed Mar 5, 2019
1 parent 3473285 commit 7e691e5
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 42 deletions.
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ There are several optional parameters that could be passed into `CreateVolumeReq

2. Enable the flag `--allow-privileged=true` in the manifest entries of kubelet and kube-apiserver.

3. Add `--feature-gates=CSINodeInfo=true,CSIDriverRegistry=true,VolumeSnapshotDataSource=true` in the manifest entries of kubelet and kube-apiserver. This is required to enable topology support of EBS volumes in Kubernetes and restoring volumes from snapshots.
3. Add `--feature-gates=CSINodeInfo=true,CSIDriverRegistry=true,CSIBlockVolume=true,VolumeSnapshotDataSource=true` in the manifest entries for `kube-apiserver` and `kube-controller-manager`; and `--feature-gates=CSINodeInfo=true` in the `kubelets`. This is required to enable topology support of EBS volumes in Kubernetes, using `volumeMode: Block` and restoring volumes from snapshots.

4. Install the `CSINodeInfo` CRD on the cluster using the instructions provided here: [Enabling CSINodeInfo](https://kubernetes-csi.github.io/docs/csi-node-info-object.html#enabling-csinodeinfo).

Expand Down Expand Up @@ -95,10 +95,10 @@ kubectl apply -f deploy/kubernetes

Now any user can start creating and using EBS volumes with the CSI driver.

6. Apply `examples/kubernetes/volume_scheduling` that uses the recently deployed driver:
6. Apply `examples/kubernetes/dynamic-scheduling` that uses the recently deployed driver:

```
kubectl apply -f examples/kubernetes/volume_scheduling
kubectl apply -f examples/kubernetes/dynamic-scheduling
```

## Development
Expand Down
29 changes: 29 additions & 0 deletions examples/kubernetes/dynamic-scheduling/README.md
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.
95 changes: 60 additions & 35 deletions examples/kubernetes/snapshot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,66 @@

## 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` and `kube-controller-manager`.

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
```
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
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ebs-restore-claim
name: ebs-snapshot-restored-claim
spec:
accessModes:
- ReadWriteOnce
storageClassName: ebs-sc
resources:
requests:
storage: 2Gi
storage: 4Gi
dataSource:
name: ebs-volume-snapshot
kind: VolumeSnapshot
Expand Down
17 changes: 17 additions & 0 deletions examples/kubernetes/snapshot/specs/snapshot-restore/pod.yaml
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: VolumeSnapshot
metadata:
name: ebs-volume-snapshot
spec:
snapshotClassName: csi-aws-snapclass
snapshotClassName: csi-aws-vsc
source:
name: ebs-claim
kind: PersistentVolumeClaim
5 changes: 5 additions & 0 deletions hack/feature-gates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
CSIDriverRegistry: "true"
CSINodeInfo: "true"
CSIBlockVolume: "true"
VolumeSnapshotDataSource: "true"
kubelet:
featureGates:
CSINodeInfo: "true"
kubeControllerManager:
featureGates:
CSIDriverRegistry: "true"
CSINodeInfo: "true"
CSIBlockVolume: "true"
VolumeSnapshotDataSource: "true"

0 comments on commit 7e691e5

Please sign in to comment.