Can a Persistent Volume be resized?

前端 未结 6 1728
悲哀的现实
悲哀的现实 2020-12-23 10:05

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 l

6条回答
  •  既然无缘
    2020-12-23 10:38

    In terms of PVC/PV 'resizing', that's still not supported in k8s, though I believe it could potentially arrive in 1.9

    It's possible to achieve the same end result by dealing with PVC/PV and (e.g.) GCE PD though..

    For example, I had a gitlab deployment, with a PVC and a dynamically provisioned PV via a StorageClass resource. Here are the steps I ran through:

    1. Take a snapshot of the PD (provided you care about the data)
    2. Ensure the ReclaimPolicy of the PV is "Retain", patch if necessary as detailed here: https://kubernetes.io/docs/tasks/administer-cluster/change-pv-reclaim-policy/
    3. kubectl describe pv (useful when creating the PV manifest later)
    4. Delete the deployment/pod (probably not essential, but seems cleaner)
    5. Delete PVC and PV
    6. Ensure PD is recognised as being not in use by anything (e.g. google console, compute/disks page)
    7. Resize PD with cloud provider (with GCE, for example, this can actually be done at an earlier stage, even if the disk is in use)
    8. Create k8s PersistentVolume manifest (this had previously been done dynamically via the use of the StorageClass resource). In the PersistentVolume yaml spec, I had "gcePersistentDisk: pdName: " defined, along with other details that I'd grabbed at step 3. make sure you update the spec.capacity.storage to the new capacity you want the PV to have (although not essential, and has no effect here, you may want to update the storage capacity/value in your PVC manifest, for posterity)
    9. kubectl apply (or equivalent) to recreate your deployment/pod, PVC and PV

    note: some steps may not be essential, such as deleting some of the existing deployment/pod.. resources, though I personally prefer to remove them, seeing as I know the ReclaimPolicy is Retain, and I have a snapshot.

提交回复
热议问题