Skip to content
Permalink
Browse files

Add documentations for volume resizing

  • Loading branch information...
leakingtapan committed Jun 29, 2019
1 parent f23d7d7 commit c8d83131619a11ec6539aa197c0821e2461e2390
Showing with 81 additions and 0 deletions.
  1. +2 −0 docs/README.md
  2. +43 −0 examples/kubernetes/resizing/README.md
  3. +36 −0 examples/kubernetes/resizing/spec/example.yaml
@@ -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 size.

## 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).
@@ -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`.
@@ -0,0 +1,43 @@
## Volume Resizing
This example shows how to resize EBS persistence volume using volume resizing features.

**Note**
1. CSI volume resizing is still alpha as of Kubernetes 1.15
2. EBS has a limit of one volume modification every 6 hours. Refer to [EBS documentation](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifyVolume.html) for more details.

## 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/
```
@@ -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 c8d8313

Please sign in to comment.
You can’t perform that action at this time.