Skip to content

Commit 5ebf07d

Browse files
authored
Merge pull request #44373 from carlory/translate-blog-kubernetes-1-29-volume-attributes-class
[zh] Kubernetes 1.29: VolumeAttributesClass for Volume Modification
2 parents 62f2cdf + 9263e75 commit 5ebf07d

File tree

1 file changed

+257
-0
lines changed
  • content/zh-cn/blog/_posts/2023-12-15-volume-attributes-class

1 file changed

+257
-0
lines changed
Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
---
2+
layout: blog
3+
title: "Kubernetes 1.29:修改卷之 VolumeAttributesClass"
4+
date: 2023-12-15
5+
slug: kubernetes-1-29-volume-attributes-class
6+
---
7+
<!--
8+
layout: blog
9+
title: "Kubernetes 1.29: VolumeAttributesClass for Volume Modification"
10+
date: 2023-12-15
11+
slug: kubernetes-1-29-volume-attributes-class
12+
-->
13+
14+
<!--
15+
**Author**: Sunny Song (Google)
16+
-->
17+
**作者**:Sunny Song (Google)
18+
19+
**译者**[Baofa Fan](https://github.com/carlory) (DaoCloud)
20+
21+
<!--
22+
The v1.29 release of Kubernetes introduced an alpha feature to support modifying a volume
23+
by changing the `volumeAttributesClassName` that was specified for a PersistentVolumeClaim (PVC).
24+
With the feature enabled, Kubernetes can handle updates of volume attributes other than capacity.
25+
Allowing volume attributes to be changed without managing it through different
26+
provider's APIs directly simplifies the current flow.
27+
28+
You can read about VolumeAttributesClass usage details in the Kubernetes documentation
29+
or you can read on to learn about why the Kubernetes project is supporting this feature.
30+
-->
31+
Kubernetes v1.29 版本引入了一个 Alpha 功能,支持通过变更 PersistentVolumeClaim(PVC)的
32+
`volumeAttributesClassName` 字段来修改卷。启用该功能后,Kubernetes 可以处理除容量以外的卷属性的更新。
33+
允许更改卷属性,而无需通过不同提供商的 API 对其进行管理,这直接简化了当前流程。
34+
35+
你可以在 Kubernetes 文档中,阅读有关 VolumeAttributesClass 的详细使用信息,或者继续阅读了解
36+
Kubernetes 项目为什么支持此功能。
37+
38+
## VolumeAttributesClass
39+
40+
<!--
41+
The new `storage.k8s.io/v1alpha1` API group provides two new types:
42+
-->
43+
新的 `storage.k8s.io/v1alpha1` API 组提供了两种新类型:
44+
45+
**VolumeAttributesClass**
46+
47+
<!--
48+
Represents a specification of mutable volume attributes defined by the CSI driver.
49+
The class can be specified during dynamic provisioning of PersistentVolumeClaims,
50+
and changed in the PersistentVolumeClaim spec after provisioning.
51+
-->
52+
表示由 CSI 驱动程序定义的可变卷属性的规约。你可以在 PersistentVolumeClaim 动态制备时指定它,
53+
并且允许在制备完成后在 PersistentVolumeClaim 规约中进行更改。
54+
55+
**ModifyVolumeStatus**
56+
57+
<!--
58+
Represents the status object of `ControllerModifyVolume` operation.
59+
-->
60+
表示 `ControllerModifyVolume` 操作的状态对象。
61+
62+
<!--
63+
With this alpha feature enabled, the spec of PersistentVolumeClaim defines VolumeAttributesClassName
64+
that is used in the PVC. At volume provisioning, the `CreateVolume` operation will apply the parameters in the
65+
VolumeAttributesClass along with the parameters in the StorageClass.
66+
-->
67+
68+
启用此 Alpha 功能后,PersistentVolumeClaim 的 `spec.VolumeAttributesClassName` 字段指明了在 PVC 中使用的 VolumeAttributesClass。
69+
在制备卷时,`CreateVolume` 操作将应用 VolumeAttributesClass 中的参数以及 StorageClass 中的参数。
70+
71+
<!--
72+
When there is a change of volumeAttributesClassName in the PVC spec,
73+
the external-resizer sidecar will get an informer event. Based on the current state of the configuration,
74+
the resizer will trigger a CSI ControllerModifyVolume.
75+
More details can be found in [KEP-3751](https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/3751-volume-attributes-class/README.md).
76+
-->
77+
当 PVC 的 `spec.VolumeAttributesClassName` 发生变化时,external-resizer sidecar 将会收到一个 informer 事件。
78+
基于当前的配置状态,resizer 将触发 CSI ControllerModifyVolume。更多细节可以在
79+
[KEP-3751](https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/3751-volume-attributes-class/README.md) 中找到。
80+
81+
<!--
82+
## How to use it
83+
84+
If you want to test the feature whilst it's alpha, you need to enable the relevant feature gate
85+
in the `kube-controller-manager` and the `kube-apiserver`. Use the `--feature-gates` command line argument:
86+
-->
87+
## 如何使用它
88+
89+
如果你想在 Alpha 版本中测试该功能,需要在 `kube-controller-manager``kube-apiserver` 中启用相关的特性门控。
90+
使用 `--feature-gates` 命令行参数:
91+
92+
```
93+
--feature-gates="...,VolumeAttributesClass=true"
94+
```
95+
96+
<!--
97+
It also requires that the CSI driver has implemented the ModifyVolume API.
98+
-->
99+
它还需要 CSI 驱动程序实现 ModifyVolume API。
100+
101+
<!--
102+
### User flow
103+
104+
If you would like to see the feature in action and verify it works fine in your cluster, here's what you can try:
105+
-->
106+
### 用户流程
107+
108+
如果你想看到该功能的运行情况,并验证它在你的集群中是否正常工作,可以尝试以下操作:
109+
110+
<!--
111+
1. Define a StorageClass and VolumeAttributesClass
112+
-->
113+
1. 定义 StorageClass 和 VolumeAttributesClass
114+
115+
```yaml
116+
apiVersion: storage.k8s.io/v1
117+
kind: StorageClass
118+
metadata:
119+
name: csi-sc-example
120+
provisioner: pd.csi.storage.gke.io
121+
parameters:
122+
disk-type: "hyperdisk-balanced"
123+
volumeBindingMode: WaitForFirstConsumer
124+
```
125+
126+
127+
```yaml
128+
apiVersion: storage.k8s.io/v1alpha1
129+
kind: VolumeAttributesClass
130+
metadata:
131+
name: silver
132+
driverName: pd.csi.storage.gke.io
133+
parameters:
134+
provisioned-iops: "3000"
135+
provisioned-throughput: "50"
136+
```
137+
138+
<!--
139+
2. Define and create the PersistentVolumeClaim
140+
-->
141+
2. 定义并创建 PersistentVolumeClaim
142+
143+
```yaml
144+
apiVersion: v1
145+
kind: PersistentVolumeClaim
146+
metadata:
147+
name: test-pv-claim
148+
spec:
149+
storageClassName: csi-sc-example
150+
volumeAttributesClassName: silver
151+
accessModes:
152+
- ReadWriteOnce
153+
resources:
154+
requests:
155+
storage: 64Gi
156+
```
157+
158+
<!--
159+
3. Verify that the PersistentVolumeClaim is now provisioned correctly with:
160+
-->
161+
3. 验证 PersistentVolumeClaim 是否已正确制备:
162+
163+
```
164+
kubectl get pvc
165+
```
166+
167+
<!--
168+
4. Create a new VolumeAttributesClass gold:
169+
-->
170+
4. 创建一个新的名为 gold 的 VolumeAttributesClass:
171+
172+
```yaml
173+
apiVersion: storage.k8s.io/v1alpha1
174+
kind: VolumeAttributesClass
175+
metadata:
176+
name: gold
177+
driverName: pd.csi.storage.gke.io
178+
parameters:
179+
iops: "4000"
180+
throughput: "60"
181+
```
182+
183+
<!--
184+
5. Update the PVC with the new VolumeAttributesClass and apply:
185+
-->
186+
5. 使用新的 VolumeAttributesClass 更新 PVC 并应用:
187+
188+
```yaml
189+
apiVersion: v1
190+
kind: PersistentVolumeClaim
191+
metadata:
192+
name: test-pv-claim
193+
spec:
194+
storageClassName: csi-sc-example
195+
volumeAttributesClassName: gold
196+
accessModes:
197+
- ReadWriteOnce
198+
resources:
199+
requests:
200+
storage: 64Gi
201+
```
202+
203+
<!--
204+
6. Verify that PersistentVolumeClaims has the updated VolumeAttributesClass parameters with:
205+
-->
206+
6. 验证 PersistentVolumeClaims 是否具有更新的 VolumeAttributesClass 参数:
207+
208+
```
209+
kubectl describe pvc <PVC_NAME>
210+
```
211+
212+
<!--
213+
## Next steps
214+
215+
* See the [VolumeAttributesClass KEP](https://kep.k8s.io/3751) for more information on the design
216+
* You can view or comment on the [project board](https://github.com/orgs/kubernetes-csi/projects/72) for VolumeAttributesClass
217+
* In order to move this feature towards beta, we need feedback from the community,
218+
so here's a call to action: add support to the CSI drivers, try out this feature,
219+
consider how it can help with problems that your users are having…
220+
-->
221+
## 后续步骤
222+
223+
* 有关设计的更多信息,请参阅 [VolumeAttributesClass KEP](https://kep.k8s.io/3751)
224+
* 你可以在[项目看板](https://github.com/orgs/kubernetes-csi/projects/72)上查看或评论 VolumeAttributesClass
225+
* 为了将此功能推向 Beta 版本,我们需要社区的反馈,因此这里有一个行动倡议:为 CSI 驱动程序添加支持,
226+
尝试此功能,考虑它如何帮助解决你的用户遇到的问题...
227+
228+
<!--
229+
## Getting involved
230+
231+
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).
232+
-->
233+
## 参与其中
234+
235+
我们始终欢迎新的贡献者。因此,如果你想参与其中,可以加入我们的
236+
[Kubernetes 存储特别兴趣小组](https://github.com/kubernetes/community/tree/master/sig-storage) (SIG)。
237+
238+
<!--
239+
If you would like to share feedback, you can do so on our [public Slack channel](https://app.slack.com/client/T09NY5SBT/C09QZFCE5).
240+
-->
241+
如果你想分享反馈意见,可以在我们的[公共 Slack 频道](https://app.slack.com/client/T09NY5SBT/C09QZFCE5) 上留言。
242+
243+
<!--
244+
Special thanks to all the contributors that provided great reviews, shared valuable insight and helped implement this feature (alphabetical order):
245+
-->
246+
特别感谢所有为此功能提供了很好的评论、分享了宝贵见解并帮助实现此功能的贡献者(按字母顺序):
247+
248+
* Baofa Fan (calory)
249+
* Ben Swartzlander (bswartz)
250+
* Connor Catlett (ConnorJC3)
251+
* Hemant Kumar (gnufied)
252+
* Jan Šafránek (jsafrane)
253+
* Joe Betz (jpbetz)
254+
* Jordan Liggitt (liggitt)
255+
* Matthew Cary (mattcary)
256+
* Michelle Au (msau42)
257+
* Xing Yang (xing-yang)

0 commit comments

Comments
 (0)