How to provision a pv/pvc in k8s and expand the pvc?

ok, so I know this really seams like a silly question, however I am trying to wrap my head around this idea. My experience is coming from Digital Ocean when when you provision a pvc, you automatically get a block storage device from DO.

I see that happening on my cluster using longhorn. Here is the issue, when I try to go to expand the pvc it gives me a error saying that it cant expand a dynamically created pvc.

Ok now this make sense, because the underlying block is the same size as the pvc. So we can’t expand the block(pv) from k8s.

So reading more I find longhorn-static as a storageclass. I manually created a 20gi block/pv using the longhorn ui. Then I go into k8s and create a pvc with the following:

piVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: brad-pvc
  namespace:user
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
  volumeName: testvolume
  storageClassName: longhorn-static
  volumeMode: Filesystem

This works fine. However I am still not able to expand the PVC even though the underlying pv is 20g. What am I missing? thanks for having a look, any suggestions are welcome.

Brad

  1. Longhorn supports over-provisioning, this means you would create a Longhorn volume of which the spec size can be greater than the underlying block device (but the actual size of the volume cannot break the physical limit).
  2. Aren’t your PVC and PV size match exactly? There is no need to make the PV size the same as the block device size. You may misunderstand the concept. Instead, it should be the same as the PVC size. The expansion would fail when the expanded size is smaller than the current PVC/PV/Longhorn volume size