Skip to content

Commit 00d37e5

Browse files
authored
Merge pull request #33593 from zhangxyjlu/volume-populators-beta
[zh]Add 2022-05-16-volume-populators-beta.md
2 parents 8a530c3 + 30c5e35 commit 00d37e5

File tree

1 file changed

+256
-0
lines changed

1 file changed

+256
-0
lines changed
Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
---
2+
layout: blog
3+
title: "Kubernetes 1.24: 卷填充器功能进入 Beta 阶段"
4+
date: 2022-05-16
5+
slug: volume-populators-beta
6+
---
7+
<!--
8+
layout: blog
9+
title: "Kubernetes 1.24: Volume Populators Graduate to Beta"
10+
date: 2022-05-16
11+
slug: volume-populators-beta
12+
-->
13+
14+
<!--
15+
**Author:**
16+
Ben Swartzlander (NetApp)
17+
-->
18+
**作者:**
19+
Ben Swartzlander (NetApp)
20+
21+
<!--
22+
The volume populators feature is now two releases old and entering beta! The `AnyVolumeDataSouce` feature
23+
gate defaults to enabled in Kubernetes v1.24, which means that users can specify any custom resource
24+
as the data source of a PVC.
25+
-->
26+
卷填充器功能现在已经经历两个发行版本并进入 Beta 阶段!
27+
在 Kubernetes v1.24 中 `AnyVolumeDataSouce` 特性门控默认被启用。
28+
这意味着用户可以指定任何自定义资源作为 PVC 的数据源。
29+
30+
<!--
31+
An [earlier blog article](/blog/2021/08/30-volume-populators-redesigned/) detailed how the
32+
volume populators feature works. In short, a cluster administrator can install a CRD and
33+
associated populator controller in the cluster, and any user who can create instances of
34+
the CR can create pre-populated volumes by taking advantage of the populator.
35+
-->
36+
[之前的一篇博客](/blog/2021/08/30-volume-populators-alpha/)详细介绍了卷填充器功能的工作原理。
37+
简而言之,集群管理员可以在集群中安装 CRD 和相关的填充器控制器,
38+
任何可以创建 CR 实例的用户都可以利用填充器创建预填充卷。
39+
40+
<!--
41+
Multiple populators can be installed side by side for different purposes. The SIG storage
42+
community is already seeing some implementations in public, and more prototypes should
43+
appear soon.
44+
-->
45+
出于不同的目的,可以一起安装多个填充器。存储 SIG 社区已经有了一些公开的实现,更多原型应该很快就会出现。
46+
47+
<!--
48+
Cluster administrations are **strongly encouraged** to install the
49+
volume-data-source-validator controller and associated `VolumePopulator` CRD before installing
50+
any populators so that users can get feedback about invalid PVC data sources.
51+
-->
52+
**强烈建议**集群管理人员在安装任何填充器之前安装 volume-data-source-validator 控制器和相关的
53+
`VolumePopulator` CRD,以便用户可以获得有关无效 PVC 数据源的反馈。
54+
55+
<!--
56+
## New Features
57+
-->
58+
## 新功能
59+
60+
<!--
61+
The [lib-volume-populator](https://github.com/kubernetes-csi/lib-volume-populator) library
62+
on which populators are built now includes metrics to help operators monitor and detect
63+
problems. This library is now beta and latest release is v1.0.1.
64+
-->
65+
构建填充器的 [lib-volume-populator](https://github.com/kubernetes-csi/lib-volume-populator)
66+
库现在包含可帮助操作员监控和检测问题的指标。这个库现在是 beta 阶段,最新版本是 v1.0.1。
67+
68+
<!--
69+
The [volume data source validator](https://github.com/kubernetes-csi/volume-data-source-validator)
70+
controller also has metrics support added, and is in beta. The `VolumePopulator` CRD is
71+
beta and the latest release is v1.0.1.
72+
-->
73+
[卷数据源校验器](https://github.com/kubernetes-csi/volume-data-source-validator)控制器也添加了指标支持,
74+
处于 beta 阶段。`VolumePopulator` CRD 是 beta 阶段,最新版本是 v1.0.1。
75+
76+
<!--
77+
## Trying it out
78+
-->
79+
## 尝试一下
80+
81+
<!--
82+
To see how this works, you can install the sample "hello" populator and try it
83+
out.
84+
-->
85+
要查看它是如何工作的,你可以安装 “hello” 示例填充器并尝试一下。
86+
87+
<!--
88+
First install the volume-data-source-validator controller.
89+
-->
90+
首先安装 volume-data-source-validator 控制器。
91+
92+
```shell
93+
kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/volume-data-source-validator/v1.0.1/client/config/crd/populator.storage.k8s.io_volumepopulators.yaml
94+
kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/volume-data-source-validator/v1.0.1/deploy/kubernetes/rbac-data-source-validator.yaml
95+
kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/volume-data-source-validator/v1.0.1/deploy/kubernetes/setup-data-source-validator.yaml
96+
```
97+
<!--
98+
Next install the example populator.
99+
-->
100+
接下来安装 hello 示例填充器。
101+
102+
```shell
103+
kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/lib-volume-populator/v1.0.1/example/hello-populator/crd.yaml
104+
kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/lib-volume-populator/87a47467b86052819e9ad13d15036d65b9a32fbb/example/hello-populator/deploy.yaml
105+
```
106+
<!--
107+
Your cluster now has a new CustomResourceDefinition that provides a test API named Hello.
108+
Create an instance of the `Hello` custom resource, with some text:
109+
-->
110+
你的集群现在有一个新的 CustomResourceDefinition,它提供了一个名为 Hello 的测试 API。
111+
创建一个 `Hello` 自定义资源的实例,内容如下:
112+
113+
```yaml
114+
apiVersion: hello.example.com/v1alpha1
115+
kind: Hello
116+
metadata:
117+
name: example-hello
118+
spec:
119+
fileName: example.txt
120+
fileContents: Hello, world!
121+
```
122+
<!--
123+
Create a PVC that refers to that CR as its data source.
124+
-->
125+
创建一个将该 CR 引用为其数据源的 PVC。
126+
127+
```yaml
128+
apiVersion: v1
129+
kind: PersistentVolumeClaim
130+
metadata:
131+
name: example-pvc
132+
spec:
133+
accessModes:
134+
- ReadWriteOnce
135+
resources:
136+
requests:
137+
storage: 10Mi
138+
dataSourceRef:
139+
apiGroup: hello.example.com
140+
kind: Hello
141+
name: example-hello
142+
volumeMode: Filesystem
143+
```
144+
<!--
145+
Next, run a Job that reads the file in the PVC.
146+
-->
147+
接下来,运行一个读取 PVC 中文件的 Job。
148+
149+
```yaml
150+
apiVersion: batch/v1
151+
kind: Job
152+
metadata:
153+
name: example-job
154+
spec:
155+
template:
156+
spec:
157+
containers:
158+
- name: example-container
159+
image: busybox:latest
160+
command:
161+
- cat
162+
- /mnt/example.txt
163+
volumeMounts:
164+
- name: vol
165+
mountPath: /mnt
166+
restartPolicy: Never
167+
volumes:
168+
- name: vol
169+
persistentVolumeClaim:
170+
claimName: example-pvc
171+
```
172+
<!--
173+
Wait for the job to complete (including all of its dependencies).
174+
-->
175+
等待 Job 完成(包括其所有依赖项)。
176+
177+
```shell
178+
kubectl wait --for=condition=Complete job/example-job
179+
```
180+
181+
<!--
182+
And last examine the log from the job.
183+
-->
184+
最后检查 Job 中的日志。
185+
186+
```shell
187+
kubectl logs job/example-job
188+
```
189+
<!--
190+
The output should be:
191+
-->
192+
输出应该是:
193+
194+
```terminal
195+
Hello, world!
196+
```
197+
<!--
198+
Note that the volume already contained a text file with the string contents from
199+
the CR. This is only the simplest example. Actual populators can set up the volume
200+
to contain arbitrary contents.
201+
-->
202+
请注意,该卷已包含一个文本文件,其中包含来自 CR 的字符串内容。这只是最简单的例子。
203+
实际填充器可以将卷设置为包含任意内容。
204+
205+
<!--
206+
## How to write your own volume populator
207+
-->
208+
## 如何编写自己的卷填充器
209+
210+
<!--
211+
Developers interested in writing new poplators are encouraged to use the
212+
[lib-volume-populator](https://github.com/kubernetes-csi/lib-volume-populator) library
213+
and to only supply a small controller wrapper around the library, and a pod image
214+
capable of attaching to volumes and writing the appropriate data to the volume.
215+
-->
216+
鼓励有兴趣编写新的填充器的开发人员使用
217+
[lib-volume-populator](https://github.com/kubernetes-csi/lib-volume-populator) 库,
218+
只提供一个小型控制器,以及一个能够连接到卷并向卷写入适当数据的 Pod 镜像。
219+
220+
<!--
221+
Individual populators can be extremely generic such that they work with every type
222+
of PVC, or they can do vendor specific things to rapidly fill a volume with data
223+
if the volume was provisioned by a specific CSI driver from the same vendor, for
224+
example, by communicating directly with the storage for that volume.
225+
-->
226+
单个填充器非常通用,它们可以与所有类型的 PVC 一起使用,
227+
或者如果卷是来自同一供应商的特定 CSI 驱动程序供应的,
228+
它们可以执行供应商特定的的操作以快速用数据填充卷,例如,通过通信直接使用该卷的存储。
229+
230+
<!--
231+
## How can I learn more?
232+
-->
233+
## 我怎样才能了解更多?
234+
235+
<!--
236+
The enhancement proposal,
237+
[Volume Populators](https://github.com/kubernetes/enhancements/tree/master/keps/sig-storage/1495-volume-populators), includes lots of detail about the history and technical implementation
238+
of this feature.
239+
-->
240+
增强提案,
241+
[卷填充器](https://github.com/kubernetes/enhancements/tree/master/keps/sig-storage/1495-volume-populators)
242+
包含有关此功能的历史和技术实现的许多详细信息。
243+
244+
<!--
245+
[Volume populators and data sources](/docs/concepts/storage/persistent-volumes/#volume-populators-and-data-sources), within the documentation topic about persistent volumes,
246+
explains how to use this feature in your cluster.
247+
-->
248+
[卷填充器与数据源](/zh/docs/concepts/storage/persistent-volumes/#volume-populators-and-data-sources),
249+
在有关持久卷的文档主题中,解释了如何在集群中使用此功能。
250+
251+
<!--
252+
Please get involved by joining the Kubernetes storage SIG to help us enhance this
253+
feature. There are a lot of good ideas already and we'd be thrilled to have more!
254+
-->
255+
请加入 Kubernetes 的存储 SIG,帮助我们增强这一功能。这里已经有很多好的主意了,我们很高兴能有更多!
256+

0 commit comments

Comments
 (0)