Skip to content

Commit

Permalink
Add documentations for volume resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheng Pan committed Aug 11, 2019
1 parent f23d7d7 commit e85af77
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/README.md
Expand Up @@ -66,6 +66,7 @@ Following sections are Kubernetes specific. If you are Kubernetes user, use foll
* **Block Volume** - consumes the EBS volume as a raw block device for latency sensitive application eg. MySql
* **Volume Snapshot** - creating volume snapshots and restore volume from snapshot.
* **NVMe** - consume NVMe EBS volume from EC2 [Nitro instance](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html#ec2-nitro-instances).
* **Volume Resizing** - expand the volume resize.

## Prerequisites
* If you are managing EBS volumes using static provisioning, get yourself familiar with [EBS volume](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AmazonEBS.html).
Expand Down Expand Up @@ -107,6 +108,7 @@ Make sure you follow the [Prerequisites](README.md#Prerequisites) before the exa
* [Block Volume](../examples/kubernetes/block-volume)
* [Volume Snapshot](../examples/kubernetes/snapshot)
* [Configure StorageClass](../examples/kubernetes/storageclass)
* [Volume Resizing](../examples/kubernetes/resizing)

## Migrating from in-tree EBS plugin
Starting from Kubernetes 1.14, CSI migration is supported as alpha feature. If you have persistence volumes that are created with in-tree `kubernetes.io/aws-ebs` plugin, you could migrate to use EBS CSI driver. To turn on the migration, set `CSIMigration` and `CSIMigrationAWS` feature gates to `true` for `kube-controller-manager` and `kubelet`.
Expand Down
41 changes: 41 additions & 0 deletions examples/kubernetes/resizing/README.md
@@ -0,0 +1,41 @@
## Volume Resizing
This example shows how to resize EBS persistence volume using volume resizing features.

Note that CSI volume resizing is still alpha as of Kubernetes 1.15.

## Usage
1. Add `allowVolumeExpansion: true` in the StorageClass spec in [example manifest](./specs/example.yaml) to enable volume expansion. You can only expand a PVC if its storage class’s allowVolumeExpansion field is set to true

2. Deploy the example:
```sh
kubectl apply -f specs/
```

3. Verify the volume is created and Pod is running:
```sh
kubectl get pv
kubectl get po app
```

4. Expand the volume size by increasing the capacity in PVC's `spec.resources.requests.storage`:
```sh
kubectl edit pvc ebs-claim
```
Save the result at the end of the edit.

5. Verify that both the persistence volume and persistence volume claim are resized:
```sh
kubectl get pv
kubectl get pvc
```
You should see that both should have the new value relfected in the capacity fields.

6. Verify that the application is continuously running without any interruption:
```sh
kubectl exec -it app cat /data/out.txt
```

7. Cleanup resources:
```
kubectl delete -f specs/
```
36 changes: 36 additions & 0 deletions examples/kubernetes/resizing/spec/example.yaml
@@ -0,0 +1,36 @@
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: resize-sc
provisioner: ebs.csi.aws.com
allowVolumeExpansion: true
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ebs-claim
spec:
accessModes:
- ReadWriteOnce
storageClassName: resize-sc
resources:
requests:
storage: 4Gi
---
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-claim

0 comments on commit e85af77

Please sign in to comment.