only dynamically provisioned pvc can be resized and the storageclass that provisions the pvc must support resize

4,562 views
Skip to first unread message

apurv barve

unread,
Jul 22, 2020, 9:35:54 AM7/22/20
to container-storage-interface-community, container-storage-inte...@googlegroups.com
Hi,

Does CSI not allow resize of volumes which were statically created and later consumed by creating SC, PV and PVC? 

--
Regards,
Apurv

Saad Ali

unread,
Jul 22, 2020, 7:29:31 PM7/22/20
to apurv barve, Hemant Kumar, container-storage-interface-community

--
You received this message because you are subscribed to the Google Groups "container-storage-interface-community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to container-storage-interf...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/container-storage-interface-community/CAA%2BnuU0kqRQS1aTWUvUA5OHth8L8A0FaKT-mxrwybYHO%3DHGASg%40mail.gmail.com.

apurv barve

unread,
Jul 24, 2020, 5:41:35 AM7/24/20
to Saad Ali, Hemant Kumar, container-storage-interface-community
Hi Hemant, Saad,

Would you be able to help with this query?
Does CSI not allow resize of volumes which were statically created and later consumed by creating SC, PV and PVC? 
We saw error when we tried to resize even when we have allowVolumeExpansion = true in SC and CSI driver implements resize functionality:

#  kubectl patch pvc csi-infoscale-pvc  --patch '{"spec": {"resources": {"requests": {"storage": "30Gi"}}}}'

Error from server (Forbidden): persistentvolumeclaims "csi-infoscale-pvc" is forbidden: only dynamically provisioned pvc can be resized and the storageclass that provisions the pvc must support resize


Regards,
Apurv

Hemant Kumar

unread,
Jul 24, 2020, 7:51:27 AM7/24/20
to apurv barve, Saad Ali, container-storage-interface-community
Hello Apurv,

Kubernetes by default only allows expansion of PVCs that have
"allowExpansion" set to true in their storageClass -
https://kubernetes.io/docs/concepts/storage/persistent-volumes/#expanding-persistent-volumes-claims

There is some historic reasoning for this decision, such as expansion
being more expensive in some cases and an k8s admin wanting to control
which PVCs can be allowed to expand.

apurv barve

unread,
Jul 24, 2020, 8:49:49 AM7/24/20
to Hemant Kumar, Saad Ali, container-storage-interface-community
Thanks for the response Hemant. But we have set  "allowVolumeExpansion = true" in Storage Class.
My question is mainly for static volumes & the error message also talks about resize not being allowed for static volumes. 

Error from server (Forbidden): persistentvolumeclaims "csi-infoscale-pvc" is forbidden: only dynamically provisioned pvc can be resized and the storageclass that provisions the pvc must support resize  

If the underlying CSI driver is capable of handling resize of static provisioned volumes, why is it being prevented?

--
Regards,
Apurv

Ben Swartzlander

unread,
Jul 24, 2020, 9:38:37 AM7/24/20
to container-storage-...@googlegroups.com
On 7/24/20 8:49 AM, apurv barve wrote:
> Thanks for the response Hemant. But we have set  "allowVolumeExpansion =
> true" in Storage Class.
> My question is mainly for static volumes & the error message also talks
> about resize not being allowed for static volumes.
>
> Error from server (Forbidden): persistentvolumeclaims
> "csi-infoscale-pvc" is forbidden: *only dynamically provisioned pvc can
> be resized* and the storageclass that provisions the pvc must support
> resize
>
> If the underlying CSI driver is capable of handling resize of static
> provisioned volumes, why is it being prevented?

I think the error message may be misleading. The error message is
generated by the admission controller, and all it does is the following
checks:
* Make sure the PVC has a storage class name
* Make sure the storage class isn't being changed
* Make sure the storage class by that name exists
* Make sure the storage class allows volume expansion

Presumably the "only dynamically provisioned" part of the error message
refers to the need for the storage class to be set. A statically
provisioned PVC doesn't need a storage class.

I'm not sure why it's failing in your case. Are you attempting to modify
the storage class at the same time you change the size?

-Ben
> <mailto:container-storage-interface-community%2Bunsu...@googlegroups.com>.
> --
> You received this message because you are subscribed to the Google
> Groups "container-storage-interface-community" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
> container-storage-interf...@googlegroups.com
> <mailto:container-storage-interf...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/container-storage-interface-community/CAA%2BnuU15LFxmsx3c%3DoH2kNucgzy-%2BEuctmr%2B2xzQ7%3DqE%2B%2BrhPw%40mail.gmail.com
> <https://groups.google.com/d/msgid/container-storage-interface-community/CAA%2BnuU15LFxmsx3c%3DoH2kNucgzy-%2BEuctmr%2B2xzQ7%3DqE%2B%2BrhPw%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Sandeep P S

unread,
Jul 24, 2020, 12:37:56 PM7/24/20
to Ben Swartzlander, container-storage-interface-community
Apurv,

+1 to Ben's comments. The admission controller code that fails volume expansion is here -  https://github.com/kubernetes/kubernetes/blob/master/plugin/pkg/admission/storage/persistentvolume/resize/admission.go#L108. I just tested this - I statically provisioned a volume and I could also extend it from 1Gi to 2Gi. Basically the static PVC must have a reference to the storage class(with AllowVolumeExpansion set to true) and must be bound to a static PV(that needs to be extended).

Thanks,
Sandeep

To unsubscribe from this group and stop receiving emails from it, send an email to container-storage-interf...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/container-storage-interface-community/344262a3-605e-438f-223c-2ca5a51f5fa5%40swartzlander.org.

apurv barve

unread,
Jul 28, 2020, 8:11:20 AM7/28/20
to Sandeep P S, Ben Swartzlander, container-storage-interface-community
Hi,

Looks like we were not associating SC correctly with the PVC for static volumes. After doing it, we are able to resize the PVC. Thanks.

-- 
Regards,
Apurv

Reply all
Reply to author
Forward
0 new messages