It seems not all storageclass support this

Basavraj Nilkanthe:
It seems not all storageclass support this

Malayamanas Panda:
@Basavraj Nilkanthe storageclass has nothng to do with a feature, it is just a classification of PV

Malayamanas Panda:
if the PV is available with 100Mi and if the matching PVC was created with 10Mi and then you need to increase that PVC to 70Mi, then either edit or patch that pvc .

Malayamanas Panda:
if matching pv is not available, still you can do that for pvc , but the pod would be in pending state

Basavraj Nilkanthe:
well, thats not true as per below document,
https://kubernetes.io/blog/2018/07/12/resizing-persistent-volumes-using-kubernetes/

Basavraj Nilkanthe:
you can do resizing by those pvc which are created with storageclass and that storage class has attributed enabled…

allowVolumeExpansion: true

Basavraj Nilkanthe:
I have tested without this., it wont work

Basavraj Nilkanthe:
now, I will test with it

Basavraj Nilkanthe:

apiVersion: <http://storage.k8s.io/v1|storage.k8s.io/v1>
kind: StorageClass
metadata:
  name: standard
parameters:
  type: pd-standard
provisioner: <http://kubernetes.io/gce-pd|kubernetes.io/gce-pd>
allowVolumeExpansion: true
reclaimPolicy: Delete

Basavraj Nilkanthe:
root@controlplane:~# kubectl edit pvc task-pv-claim
persistentvolumeclaim/task-pv-claim edited

Basavraj Nilkanthe:
well, it works

Basavraj Nilkanthe:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: task-pv-volume
  labels:
    type: local
spec:
  storageClassName: standard
  capacity:
    storage: 100Mi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/mnt/data"

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: task-pv-claim
spec:
  storageClassName: standard
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 50Mi

Basavraj Nilkanthe:
This is my existing pv and pvc

Basavraj Nilkanthe:
after patching

Basavraj Nilkanthe:

 spec:
    accessModes:
    - ReadWriteOnce
    resources:
      requests:
        storage: 70Mi
    storageClassName: standard
    volumeMode: Filesystem
    volumeName: task-pv-volume
  status:
    accessModes:
    - ReadWriteOnce
    capacity:
      storage: 100Mi
    phase: Bound
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

Basavraj Nilkanthe:

Basavraj Nilkanthe:
If I try with other storage class like manual… let see what will happen

Basavraj Nilkanthe:

root@controlplane:~# kubectl get pv
NAME             CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                   STORAGECLASS   REASON   AGE
task-pv-volume   100Mi      RWO            Retain           Bound    default/task-pv-claim   manual                  4s
root@controlplane:~# kubectl edit pvc task-pv-claim 
error: persistentvolumeclaims "task-pv-claim" could not be patched: persistentvolumeclaims "task-pv-claim" is forbidden: only dynamically provisioned pvc can be resized and the storageclass that provisions the pvc must support resize
You can run `kubectl replace -f /tmp/kubectl-edit-wr9yz.yaml` to try this update again.
root@controlplane:~# 

Basavraj Nilkanthe:
I cant edit it

Nitin:
Dynamic storage class supports this … even when PV is not available … PV will be created dynamically to accomodate pvc