Skip to content

Commit 0553a7c

Browse files
Update Based on Comments - Dec 4
1 parent 7000237 commit 0553a7c

File tree

3 files changed

+179
-162
lines changed

3 files changed

+179
-162
lines changed

content/en/blog/_posts/2023-11-20-volume-attributes-class/index.md

Lines changed: 0 additions & 162 deletions
This file was deleted.
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
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 VolumeAttributesClassName that was assigned to 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+
77+
```yaml
78+
apiVersion: storage.k8s.io/v1alpha1
79+
kind: VolumeAttributesClass
80+
metadata:
81+
name: silver
82+
driverName: pd.csi.storage.gke.io
83+
parameters:
84+
provisioned-iops: "3000"
85+
provisioned-throughput: "50"
86+
```
87+
88+
89+
2. Define and create the PersistentVolumeClaim
90+
91+
```yaml
92+
apiVersion: v1
93+
kind: PersistentVolumeClaim
94+
metadata:
95+
name: test-pv-claim
96+
spec:
97+
storageClassName: csi-sc-example
98+
volumeAttributesClassName: silver
99+
accessModes:
100+
- ReadWriteOnce
101+
resources:
102+
requests:
103+
storage: 64Gi
104+
```
105+
106+
107+
3. Verify that the PersistentVolumeClaim is now provisioned correctly with:
108+
109+
```yaml
110+
kubectl get pvc
111+
```
112+
113+
114+
4. Create a new VolumeAttributesClass gold:
115+
116+
```yaml
117+
apiVersion: storage.k8s.io/v1alpha1
118+
kind: VolumeAttributesClass
119+
metadata:
120+
name: gold
121+
driverName: pd.csi.storage.gke.io
122+
parameters:
123+
iops: "4000"
124+
throughput: "60"
125+
```
126+
127+
128+
5. Update the PVC with the new VolumeAttributesClass and apply:
129+
130+
```yaml
131+
apiVersion: v1
132+
kind: PersistentVolumeClaim
133+
metadata:
134+
name: test-pv-claim
135+
spec:
136+
storageClassName: csi-sc-example
137+
volumeAttributesClassName: gold
138+
accessModes:
139+
- ReadWriteOnce
140+
resources:
141+
requests:
142+
storage: 64Gi
143+
144+
```
145+
146+
147+
6. Verify that PersistentVolumeClaims has the updated VolumeAttributesClass parameters with:
148+
149+
```yaml
150+
kubectl describe pvc <PVC_NAME>
151+
```
152+
153+
## Next steps
154+
155+
* See the [VolumeAttributesClass KEP](https://kep.k8s.io/3751) for more information on the design
156+
* You can view or comment on the [project board](https://github.com/orgs/kubernetes-csi/projects/72) for VolumeAttributesClass
157+
* In order to move this feature towards beta, we need feedback from the community,
158+
so here's a call to action: add support to the CSI drivers, try out this feature,
159+
consider how it can help with problems that your users are having…
160+
161+
162+
## Getting involved
163+
164+
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).
165+
166+
If you would like to share feedback, you can do so on our [public Slack channel](https://app.slack.com/client/T09NY5SBT/C09QZFCE5).
167+
168+
Special thanks to all the contributors that provided great reviews, shared valuable insight and helped implement this feature (alphabetical order):
169+
170+
* Baofa Fan (calory)
171+
* Ben Swartzlander (bswartz)
172+
* Connor Catlett (ConnorJC3)
173+
* Hemant Kumar (gnufied)
174+
* Jan Šafránek (jsafrane)
175+
* Joe Betz (jpbetz)
176+
* Jordan Liggitt (liggitt)
177+
* Matthew Cary (mattcary)
178+
* Michelle Au (msau42)
179+
* Xing Yang (xing-yang)

0 commit comments

Comments
 (0)