Feature gates:

  • enable ExpandPersistentVolumes feature gate (1.11⬆️ default:ture).
  • enable PersistentVolumeClaimResize admission controller (1.11⬆️ default:ture).

StorageClass:

  • Storage class’s allowVolumeExpansion field should set to true.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: gluster-heketi
  resourceVersion: "2557237"
  selfLink: /apis/storage.k8s.io/v1/storageclasses/gluster-heketi
  uid: 0cab6ccf-09c9-11e9-bb03-525400c73db8
parameters:
  resturl: http://10.104.202.182:8080
  restuser: admin
  restuserkey: My Secret Life
provisioner: kubernetes.io/glusterfs
reclaimPolicy: Delete
volumeBindingMode: Immediate
allowVolumeExpansion: true  # <===============

To request a larger volume for a PVC, edit the PVC object and specify a larger size. This triggers expansion of the volume that backs the underlying PersistentVolume. A new PersistentVolume is never created to satisfy the claim. Instead, an existing volume is resized.

-> kubectl edit pvc glusterfs-data-01 -n play-by-yl

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  annotations:
    pv.kubernetes.io/bind-completed: "yes"
    pv.kubernetes.io/bound-by-controller: "yes"
    storage.resource.caicloud.io/app-ids: ""
    storage.resource.caicloud.io/app-names: ""
    volume.beta.kubernetes.io/storage-provisioner: kubernetes.io/glusterfs
  creationTimestamp: 2019-01-29T10:55:26Z
  finalizers:
  - kubernetes.io/pvc-protection
  name: glusterfs-data-01
  namespace: play-by-yl
  resourceVersion: "130561"
  selfLink: /api/v1/namespaces/play-by-yl/persistentvolumeclaims/glusterfs-data-01
  uid: 62509f38-23b4-11e9-8dc1-525400f31786
spec:
  accessModes:
  - ReadWriteMany
  dataSource: null
  resources:
    requests:
      storage: 30Gi   # <== update this field to resize the PVC
  storageClassName: glusterfs-20190129164702-d41e1f
  volumeName: pvc-62509f38-23b4-11e9-8dc1-525400f31786
status:
  accessModes:
  - ReadWriteMany
  capacity:
    storage: 30Gi
  phase: Bound
  • Support following types of volumes:
    • gcePersistentDisk
    • awsElasticBlockStore
    • Cinder
    • glusterfs
    • rbd
    • Azure File
    • Azure Disk
    • Portworx
    • FlexVolumes
    • CSI
  • Resizing a volume containing a file system
    • file system is XFS, Ext3, or Ext4.
    • Pod is started using the PersistentVolumeClaim in ReadWrite mode.
    • if volume is using and you want to expand it, you need to delete or recreate the pod after the volume has been expanded by the cloud provider in the controller-manager.
    • check the status of resize operation by running the kubectl describe pvc command, if the PersistentVolumeClaim has the status FileSystemResizePending, it is safe to recreate the pod using the PersistentVolumeClaim.
    • gcePersistentDisk, awsElasticBlockStore, Azure Disk, Cinder, Ceph RBD
  • Resizing an in-use PersistentVolumeClaim
    • Expanding in-use PVCs is an alpha feature. To use it, enable the ExpandInUsePersistentVolumes feature gate (1.15⬆️ default:ture).
    • Supported by the in-tree volume plugins

Reference: