|
| 1 | +--- |
| 2 | +layout: blog |
| 3 | +title: "Kubernetes 1.31: VolumeAttributesClass for Volume Modification Beta" |
| 4 | +date: 2024-08-15 |
| 5 | +slug: kubernetes-1-31-volume-attributes-class |
| 6 | +author: > |
| 7 | + Sunny Song (Google) |
| 8 | + Matthew Cary (Google) |
| 9 | +--- |
| 10 | + |
| 11 | +Volumes in Kubernetes have been described by two attributes: their storage class, and |
| 12 | +their capacity. The storage class is an immutable property of the volume, while the |
| 13 | +capacity can be changed dynamically with [volume |
| 14 | +resize](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#expanding-persistent-volumes-claims). |
| 15 | + |
| 16 | +This complicates vertical scaling of workloads with volumes. While cloud providers and |
| 17 | +storage vendors often offer volumes which allow specifying IO quality of service |
| 18 | +(Performance) parameters like IOPS or throughput and tuning them as workloads operate, |
| 19 | +Kubernetes has no API which allows changing them. |
| 20 | + |
| 21 | +We are pleased to announce that the [VolumeAttributesClass |
| 22 | +KEP](https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/3751-volume-attributes-class/README.md), |
| 23 | +alpha since Kubernetes 1.29, will be beta in 1.31. This provides a generic, |
| 24 | +Kubernetes-native API for modifying volume parameters like provisioned IO. |
| 25 | + |
| 26 | +Like all new volume features in Kubernetes, this API is implemented via the [container |
| 27 | +storage interface (CSI)](https://kubernetes-csi.github.io/docs/). In addition to the |
| 28 | +VolumeAttributesClass feature gate, your provisioner-specific CSI driver must support the |
| 29 | +new ModifyVolume API which is the CSI side of this feature. |
| 30 | + |
| 31 | +See the [full |
| 32 | +documentation](https://kubernetes.io/docs/concepts/storage/volume-attributes-classes/) |
| 33 | +for all details. Here we show the common workflow. |
| 34 | + |
| 35 | +### Dynamically modifying volume attributes. |
| 36 | + |
| 37 | +A `VolumeAttributesClass` is a cluster-scoped resource that specifies provisioner-specific |
| 38 | +attributes. These are created by the cluster administrator in the same way as storage |
| 39 | +classes. For example, a series of gold, silver and bronze volume attribute classes can be |
| 40 | +created for volumes with greater or lessor amounts of provisioned IO. |
| 41 | + |
| 42 | +```yaml |
| 43 | +apiVersion: storage.k8s.io/v1alpha1 |
| 44 | +kind: VolumeAttributesClass |
| 45 | +metadata: |
| 46 | + name: silver |
| 47 | +driverName: your-csi-driver |
| 48 | +parameters: |
| 49 | + provisioned-iops: "500" |
| 50 | + provisioned-throughput: "50MiB/s" |
| 51 | +--- |
| 52 | +apiVersion: storage.k8s.io/v1alpha1 |
| 53 | +kind: VolumeAttributesClass |
| 54 | +metadata: |
| 55 | + name: gold |
| 56 | +driverName: your-csi-driver |
| 57 | +parameters: |
| 58 | + provisioned-iops: "10000" |
| 59 | + provisioned-throughput: "500MiB/s" |
| 60 | +``` |
| 61 | + |
| 62 | +An attribute class is added to a PVC in much the same way as a storage class. |
| 63 | +
|
| 64 | +```yaml |
| 65 | +apiVersion: v1 |
| 66 | +kind: PersistentVolumeClaim |
| 67 | +metadata: |
| 68 | + name: test-pv-claim |
| 69 | +spec: |
| 70 | + storageClassName: any-storage-class |
| 71 | + volumeAttributesClassName: silver |
| 72 | + accessModes: |
| 73 | + - ReadWriteOnce |
| 74 | + resources: |
| 75 | + requests: |
| 76 | + storage: 64Gi |
| 77 | +``` |
| 78 | +
|
| 79 | +Unlike a storage class, the volume attributes class can be changed: |
| 80 | +
|
| 81 | +``` |
| 82 | +kubectl patch pvc test-pv-claim -p '{"spec": "volumeAttributesClassName": "gold"}' |
| 83 | +``` |
| 84 | +
|
| 85 | +Kubernetes will work with the CSI driver to update the attributes of the |
| 86 | +volume. The status of the PVC will track the current and desired attributes |
| 87 | +class. The PV resource will also be updated with the new volume attributes class |
| 88 | +which will be set to the currently active attributes of the PV. |
| 89 | +
|
| 90 | +### Limitations with the beta |
| 91 | +
|
| 92 | +As a beta feature, there are still some features which are planned for GA but not yet |
| 93 | +present. The largest is quota support, see the |
| 94 | +[KEP](https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/3751-volume-attributes-class/README.md) |
| 95 | +and discussion in |
| 96 | +[sig-storage](https://github.com/kubernetes/community/tree/master/sig-storage) for details. |
| 97 | +
|
| 98 | +See the [Kubernetes CSI driver |
| 99 | +list](https://kubernetes-csi.github.io/docs/drivers.html) for up-to-date |
| 100 | +information of support for this feature in CSI drivers. |
0 commit comments