|
| 1 | +# VolumeAttributesClass for Volume Modification |
| 2 | + |
| 3 | +Kubernetes offers a method for modifying Volume parameters after they have been |
| 4 | +created. This is done through VolumeAttributesClasses and is described in a |
| 5 | +[blog |
| 6 | +post](https://kubernetes.io/blog/2025/09/08/kubernetes-v1-34-volume-attributes-class). |
| 7 | + |
| 8 | +## Prerequisites |
| 9 | + |
| 10 | +- Kubernetes 1.34 is the first release where support for |
| 11 | + VolumeAttributesClasses (the `ControllerModifyVolume` CSI procedure) is GA. |
| 12 | + Older versions of Kubernetes may not work reliably. |
| 13 | +- The Kubernetes CSI external-provisioner (`csi-provisioner` sidecar) release |
| 14 | + needs to be higher or equal to v6.1 (support for secrets). |
| 15 | +- The Kubernetes CSI external-resizer (`csi-resizer` sidecar) release |
| 16 | + needs to be higher or equal to v2.1 (support for secrets). |
| 17 | + |
| 18 | +## Secret references in the StorageClass |
| 19 | + |
| 20 | +When setting a VolumeAttributesClass on a PersistentVolumeClaim, the |
| 21 | +`ControllerModifyVolume` CSI procedure is called on the provisioner. This |
| 22 | +procedure needs secrets (that contain the Ceph credentials) in order to |
| 23 | +communicate with the Ceph cluster. Below are the keys that should be set in the |
| 24 | +StorageClass' `parameters`: |
| 25 | + |
| 26 | +- `csi.storage.k8s.io/controller-modify-secret-name` |
| 27 | +- `csi.storage.k8s.io/controller-modify-secret-namespace` |
| 28 | + |
| 29 | +In addition to the execution of `ControllerModifyVolume`, the Node-plugin needs |
| 30 | +access to the Volume on the Ceph cluster to fetch the updated parameters. |
| 31 | +Usually NFS and NVMe-oF do not need any Ceph credentials for the Node-plugin, |
| 32 | +but for using VolumeAttributesClasses to modify Volumes this is a requirement. |
| 33 | + |
| 34 | +Depending on the storage backend, Volumes are optionally _Staged_ before |
| 35 | +getting _Published_. NVMe-oF uses the staging process, and needs credentials |
| 36 | +there, hence these parameters should be set: |
| 37 | + |
| 38 | +- `csi.storage.k8s.io/node-stage-secret-name` |
| 39 | +- `csi.storage.k8s.io/node-stage-secret-namespace` |
| 40 | + |
| 41 | +NFS does not use the staging process, and only needs the credentials during the |
| 42 | +publishing process: |
| 43 | + |
| 44 | +- `csi.storage.k8s.io/node-publish-secret-name` |
| 45 | +- `csi.storage.k8s.io/node-publish-secret-namespace` |
| 46 | + |
| 47 | +## Adding support to existing Volumes |
| 48 | + |
| 49 | +PersistentVolumeClaims that have not been created with the right secret |
| 50 | +references in the StorageClass will not be modifiable with a |
| 51 | +VolumeAttributesClass without manual intervention. |
| 52 | + |
| 53 | +In order to be able to modify parameters with a VolumeAttributesClass, |
| 54 | +annotations should be added to the PersistentVolume that is _Bound_ to the |
| 55 | +PersistentVolumeClaim. These annotations should refer to the namespace and |
| 56 | +secret where the credentials are available (just like the namespace and secret |
| 57 | +that would be referenced in the StorageClass). |
| 58 | + |
| 59 | +- `volume.kubernetes.io/controller-modify-secret-name` |
| 60 | +- `volume.kubernetes.io/controller-modify-secret-namespace` |
| 61 | + |
| 62 | +Note that these annotations only make it possible for the provisioner to modify |
| 63 | +parameters. This does not allow the Node-plugin accessing the Ceph cluster to |
| 64 | +fetch updated parameters when the Volume is _staged_ or _published_. The |
| 65 | +secrets for staging and publishing can not (easily) be updated after the fact, |
| 66 | +these are part of the fixed parameters in the PersistentVolume. |
0 commit comments