Expand PV from Kubernetes no-provision storageclass

12/20/2021

I'm trying to deploy the Confluent for Kafka (zookeeper statefulset) and part of the documentation mentions that I should be able to resize it, meaning that my storageclass should have allowVolumeExpansion: true set.

While the listed supported on-prem storage solutions are only Ceph RBD and Portworx, if not using Dynamic Provisioning, the given example is of provisioner no-provisioner.

I would like to know if using a storageclass provisioner with no-provisioner does not actually allow me to resize the persistent storage volumes.

For reference:

My SC manifest is as below:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: my-storage-class
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
reclaimPolicy: Retain

I am able to create it.
As for the PV manifest, it is as below:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: data1
spec:
  capacity:
    storage: 10Gi
  volumeMode: Filesystem
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: my-storage-class
  local:
     path: /mnt/app/data1
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - node1

Then, I follow the steps below:

  • Add a new disk to my VM
  • Expand LVM vg with new disk
  • Expand LVM lv with free space
  • Change PV/PVC storage capacity and request
  • Rollout restart the sts

Once I exec into the Pod and check the FS size, it still shows 10Gb.

-- Sakk
kubernetes
persistent-volumes

2 Answers

12/21/2021

The issue was Linux side, I forgot to run resize2fs.

-- Sakk
Source: StackOverflow

12/21/2021

That's correct, you cannot set allowVolumeExpansion: true when using no-provisioner type of StorageClass (you can but it won't work). Supported types are listed here.

Expanding Persistent Volume Claims is also not supported in this type of storage.

The workaround you can try is to:

  1. Resize current StatefulSet to 0 replicas.
  2. Delete existing PV/PVC.
  3. Update the desired capacity in manifest of PV/PVC.
  4. Apply PV/PVC
  5. Resize StatefulSet to desired amount of Pods.
-- mdobrucki
Source: StackOverflow