Skip to content

Commit e0e08b7

Browse files
authored
Merge pull request #43777 from sunnylovestiramisu/blog
Add a blog post about VolumeAttributesClass
2 parents cd76d21 + 0daa5df commit e0e08b7

File tree

1 file changed

+177
-0
lines changed
  • content/en/blog/_posts/2023-12-15-volume-attributes-class

1 file changed

+177
-0
lines changed
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
---
2+
layout: blog
3+
title: "Kubernetes 1.29: VolumeAttributesClass for Volume Modification"
4+
date: 2023-12-15
5+
slug: kubernetes-1-29-volume-attributes-class
6+
---
7+
8+
**Author**: Sunny Song (Google)
9+
10+
The v1.29 release of Kubernetes introduced an alpha feature to support modifying a volume
11+
by changing the `volumeAttributesClassName` that was specified for a PersistentVolumeClaim (PVC).
12+
With the feature enabled, Kubernetes can handle updates of volume attributes other than capacity.
13+
Allowing volume attributes to be changed without managing it through different
14+
provider's APIs directly simplifies the current flow.
15+
16+
You can read about VolumeAttributesClass usage details in the Kubernetes documentation
17+
or you can read on to learn about why the Kubernetes project is supporting this feature.
18+
19+
20+
## VolumeAttributesClass
21+
22+
The new `storage.k8s.io/v1alpha1` API group provides two new types:
23+
24+
**VolumeAttributesClass**
25+
26+
Represents a specification of mutable volume attributes defined by the CSI driver.
27+
The class can be specified during dynamic provisioning of PersistentVolumeClaims,
28+
and changed in the PersistentVolumeClaim spec after provisioning.
29+
30+
**ModifyVolumeStatus**
31+
32+
Represents the status object of `ControllerModifyVolume` operation.
33+
34+
With this alpha feature enabled, the spec of PersistentVolumeClaim defines VolumeAttributesClassName
35+
that is used in the PVC. At volume provisioning, the `CreateVolume` operation will apply the parameters in the
36+
VolumeAttributesClass along with the parameters in the StorageClass.
37+
38+
When there is a change of volumeAttributesClassName in the PVC spec,
39+
the external-resizer sidecar will get an informer event. Based on the current state of the configuration,
40+
the resizer will trigger a CSI ControllerModifyVolume.
41+
More details can be found in [KEP-3751](https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/3751-volume-attributes-class/README.md).
42+
43+
## How to use it
44+
45+
If you want to test the feature whilst it's alpha, you need to enable the relevant feature gate
46+
in the `kube-controller-manager` and the `kube-apiserver`. Use the `--feature-gates` command line argument:
47+
48+
49+
```
50+
--feature-gates="...,VolumeAttributesClass=true"
51+
```
52+
53+
54+
It also requires that the CSI driver has implemented the ModifyVolume API.
55+
56+
57+
### User flow
58+
59+
If you would like to see the feature in action and verify it works fine in your cluster, here's what you can try:
60+
61+
62+
1. Define a StorageClass and VolumeAttributesClass
63+
64+
```yaml
65+
apiVersion: storage.k8s.io/v1
66+
kind: StorageClass
67+
metadata:
68+
name: csi-sc-example
69+
provisioner: pd.csi.storage.gke.io
70+
parameters:
71+
disk-type: "hyperdisk-balanced"
72+
volumeBindingMode: WaitForFirstConsumer
73+
```
74+
75+
76+
```yaml
77+
apiVersion: storage.k8s.io/v1alpha1
78+
kind: VolumeAttributesClass
79+
metadata:
80+
name: silver
81+
driverName: pd.csi.storage.gke.io
82+
parameters:
83+
provisioned-iops: "3000"
84+
provisioned-throughput: "50"
85+
```
86+
87+
88+
2. Define and create the PersistentVolumeClaim
89+
90+
```yaml
91+
apiVersion: v1
92+
kind: PersistentVolumeClaim
93+
metadata:
94+
name: test-pv-claim
95+
spec:
96+
storageClassName: csi-sc-example
97+
volumeAttributesClassName: silver
98+
accessModes:
99+
- ReadWriteOnce
100+
resources:
101+
requests:
102+
storage: 64Gi
103+
```
104+
105+
106+
3. Verify that the PersistentVolumeClaim is now provisioned correctly with:
107+
108+
```
109+
kubectl get pvc
110+
```
111+
112+
113+
4. Create a new VolumeAttributesClass gold:
114+
115+
```yaml
116+
apiVersion: storage.k8s.io/v1alpha1
117+
kind: VolumeAttributesClass
118+
metadata:
119+
name: gold
120+
driverName: pd.csi.storage.gke.io
121+
parameters:
122+
iops: "4000"
123+
throughput: "60"
124+
```
125+
126+
127+
5. Update the PVC with the new VolumeAttributesClass and apply:
128+
129+
```yaml
130+
apiVersion: v1
131+
kind: PersistentVolumeClaim
132+
metadata:
133+
name: test-pv-claim
134+
spec:
135+
storageClassName: csi-sc-example
136+
volumeAttributesClassName: gold
137+
accessModes:
138+
- ReadWriteOnce
139+
resources:
140+
requests:
141+
storage: 64Gi
142+
```
143+
144+
145+
6. Verify that PersistentVolumeClaims has the updated VolumeAttributesClass parameters with:
146+
147+
```
148+
kubectl describe pvc <PVC_NAME>
149+
```
150+
151+
## Next steps
152+
153+
* See the [VolumeAttributesClass KEP](https://kep.k8s.io/3751) for more information on the design
154+
* You can view or comment on the [project board](https://github.com/orgs/kubernetes-csi/projects/72) for VolumeAttributesClass
155+
* In order to move this feature towards beta, we need feedback from the community,
156+
so here's a call to action: add support to the CSI drivers, try out this feature,
157+
consider how it can help with problems that your users are having…
158+
159+
160+
## Getting involved
161+
162+
We always welcome new contributors. So, if you would like to get involved, you can join our [Kubernetes Storage Special Interest Group](https://github.com/kubernetes/community/tree/master/sig-storage) (SIG).
163+
164+
If you would like to share feedback, you can do so on our [public Slack channel](https://app.slack.com/client/T09NY5SBT/C09QZFCE5).
165+
166+
Special thanks to all the contributors that provided great reviews, shared valuable insight and helped implement this feature (alphabetical order):
167+
168+
* Baofa Fan (calory)
169+
* Ben Swartzlander (bswartz)
170+
* Connor Catlett (ConnorJC3)
171+
* Hemant Kumar (gnufied)
172+
* Jan Šafránek (jsafrane)
173+
* Joe Betz (jpbetz)
174+
* Jordan Liggitt (liggitt)
175+
* Matthew Cary (mattcary)
176+
* Michelle Au (msau42)
177+
* Xing Yang (xing-yang)

0 commit comments

Comments
 (0)