Author : Sunny Song (Google)
The v1.29 release of Kubernetes introduced an alpha feature to support modifying a volume by changing the
volumeAttributesClassName that was specified for a PersistentVolumeClaim (PVC). With the feature enabled, Kubernetes can handle updates of volume attributes other than capacity. Allowing volume attributes to be changed without managing it through different provider's APIs directly simplifies the current flow.
You can read about VolumeAttributesClass usage details in the Kubernetes documentation or you can read on to learn about why the Kubernetes project is supporting this feature.
storage.k8s.io/v1alpha1 API group provides two new types:
Represents a specification of mutable volume attributes defined by the CSI driver. The class can be specified during dynamic provisioning of PersistentVolumeClaims, and changed in the PersistentVolumeClaim spec after provisioning.
Represents the status object of
With this alpha feature enabled, the spec of PersistentVolumeClaim defines VolumeAttributesClassName that is used in the PVC. At volume provisioning, the
CreateVolume operation will apply the parameters in the VolumeAttributesClass along with the parameters in the StorageClass.
When there is a change of volumeAttributesClassName in the PVC spec, the external-resizer sidecar will get an informer event. Based on the current state of the configuration, the resizer will trigger a CSI ControllerModifyVolume. More details can be found in KEP-3751.
If you want to test the feature whilst it's alpha, you need to enable the relevant feature gate in the
kube-controller-manager and the
kube-apiserver. Use the
--feature-gates command line argument:
It also requires that the CSI driver has implemented the ModifyVolume API.
If you would like to see the feature in action and verify it works fine in your cluster, here's what you can try:
Define a StorageClass and VolumeAttributesClass
Define and create the PersistentVolumeClaim
Verify that the PersistentVolumeClaim is now provisioned correctly with:
Create a new VolumeAttributesClass gold:
Update the PVC with the new VolumeAttributesClass and apply:
Verify that PersistentVolumeClaims has the updated VolumeAttributesClass parameters with:
- See the VolumeAttributesClass KEP for more information on the design
- You can view or comment on the project board for VolumeAttributesClass
- In order to move this feature towards beta, we need feedback from the community, so here's a call to action: add support to the CSI drivers, try out this feature, consider how it can help with problems that your users are having…
We always welcome new contributors. So, if you would like to get involved, you can join our Kubernetes Storage Special Interest Group (SIG).
If you would like to share feedback, you can do so on our public Slack channel.
Special thanks to all the contributors that provided great reviews, shared valuable insight and helped implement this feature (alphabetical order):
- Baofa Fan (calory)
- Ben Swartzlander (bswartz)
- Connor Catlett (ConnorJC3)
- Hemant Kumar (gnufied)
- Jan Šafránek (jsafrane)
- Joe Betz (jpbetz)
- Jordan Liggitt (liggitt)
- Matthew Cary (mattcary)
- Michelle Au (msau42)
- Xing Yang (xing-yang)