Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a Persistent Volume be resized?

I'm running a MySQL deployment on Kubernetes however seems like my allocated space was not enough, initially I added a persistent volume of 50GB and now I'd like to expand that to 100GB.

I already saw the a persistent volume claim is immutable after creation, but can I somehow just resize the persistent volume and then recreate my claim?

like image 958
perrohunter Avatar asked Oct 31 '16 00:10

perrohunter


People also ask

How do you increase persistent volume in OpenShift?

To allow expansion of persistent volume claims (PVC) by OpenShift Container Platform users, OpenShift Container Platform administrators must create or update a StorageClass with allowVolumeExpansion set to true . Only PVCs created from that class are allowed to expand.

Can a persistent volume have multiple claims?

The mapping between persistentVolume and persistentVolumeClaim is always one to one. Even When you delete the claim, PersistentVolume still remains as we set persistentVolumeReclaimPolicy is set to Retain and It will not be reused by any other claims.

What happens if a pod fails while it is using a persistent volume?

Your pods can store data in volumes, but if the pod fails, that data is lost. To solve this issue, Kubernetes offers persistent volumes (PVs), which are Kubernetes resources that correspond to external storage disks or file systems that your pods can access.

What is the difference between persistent volume and persistent volume claim?

PVCs are requests for those resources and also act as claim checks to the resource. So a persistent volume (PV) is the "physical" volume on the host machine that stores your persistent data. A persistent volume claim (PVC) is a request for the platform to create a PV for you, and you attach PVs to your pods via a PVC.


2 Answers

Yes, as of 1.11, persistent volumes can be resized on certain cloud providers. To increase volume size:

  1. Edit the PVC (kubectl edit pvc $your_pvc) to specify the new size. The key to edit is spec.resources.requests.storage:

enter image description here

  1. Terminate the pod using the volume.

Once the pod using the volume is terminated, the filesystem is expanded and the size of the PV is increased. See the above link for details.

like image 185
Dmitry Minkovsky Avatar answered Sep 22 '22 08:09

Dmitry Minkovsky


It is possible in Kubernetes 1.9 (alpha in 1.8) for some volume types: gcePersistentDisk, awsElasticBlockStore, Cinder, glusterfs, rbd

It requires enabling the PersistentVolumeClaimResize admission plug-in and storage classes whose allowVolumeExpansion field is set to true.

See official docs at https://kubernetes.io/docs/concepts/storage/persistent-volumes/#expanding-persistent-volumes-claims

like image 39
csanchez Avatar answered Sep 22 '22 08:09

csanchez