@@ -27,17 +27,17 @@ PersistentVolume.
27
27
28
28
1. You create a Pod that uses the above PersistentVolumeClaim for storage.
29
29
-->
30
- 本文将向你介绍如何配置 Pod 使用
30
+ 本文将向你介绍如何配置 Pod 使用
31
31
{{< glossary_tooltip text="PersistentVolumeClaim" term_id="persistent-volume-claim" >}}
32
32
作为存储。
33
33
以下是该过程的总结:
34
34
35
- 1 . 你作为集群管理员创建由物理存储支持的 PersistentVolume。你不会将卷与任何 Pod 关联。
35
+ 1 . 你作为集群管理员创建由物理存储支持的 PersistentVolume。你不会将该卷与任何 Pod 关联。
36
36
37
37
1 . 你现在以开发人员或者集群用户的角色创建一个 PersistentVolumeClaim,
38
38
它将自动绑定到合适的 PersistentVolume。
39
39
40
- 1 . 你创建一个使用 PersistentVolumeClaim 作为存储的 Pod。
40
+ 1 . 你创建一个使用以上 PersistentVolumeClaim 作为存储的 Pod。
41
41
42
42
## {{% heading "prerequisites" %}}
43
43
@@ -56,8 +56,8 @@ do not already have a single-node cluster, you can create one by using
56
56
{{< glossary_tooltip text="kubectl" term_id="kubectl" >}} 命令行工具以便与集群交互。
57
57
如果还没有单节点集群,可以使用
58
58
[ Minikube] ( https://minikube.sigs.k8s.io/docs/ ) 创建一个。
59
- .
60
- * 熟悉[ 持久卷] ( /zh-cn/docs/concepts/storage/persistent-volumes/ ) 中的材料 。
59
+
60
+ * 熟悉[ 持久卷] ( /zh-cn/docs/concepts/storage/persistent-volumes/ ) 文档 。
61
61
62
62
<!-- steps -->
63
63
@@ -70,7 +70,7 @@ can open a shell to your Node by entering `minikube ssh`.
70
70
71
71
In your shell on that Node, create a `/mnt/data` directory:
72
72
-->
73
- ## 在你的节点上创建一个 index.html 文件
73
+ ## 在你的节点上创建一个 index.html 文件 {#create-an-index-file-on-your-node}
74
74
75
75
打开集群中的某个节点的 Shell。
76
76
如何打开 Shell 取决于集群的设置。
@@ -106,8 +106,7 @@ If your Node uses a tool for superuser access other than `sudo`, you can
106
106
usually make this work if you replace `sudo` with the name of the other tool.
107
107
-->
108
108
{{< note >}}
109
- 如果你的节点使用某工具而不是 ` sudo ` 来完成超级用户访问,你可以将上述命令
110
- 中的 ` sudo ` 替换为该工具的名称。
109
+ 如果你的节点使用某工具而不是 ` sudo ` 来完成超级用户访问,你可以将上述命令中的 ` sudo ` 替换为该工具的名称。
111
110
{{< /note >}}
112
111
113
112
<!--
@@ -118,6 +117,7 @@ Test that the `index.html` file exists:
118
117
``` shell
119
118
cat /mnt/data/index.html
120
119
```
120
+
121
121
<!--
122
122
The output should be:
123
123
-->
@@ -139,7 +139,7 @@ In this exercise, you create a *hostPath* PersistentVolume. Kubernetes supports
139
139
hostPath for development and testing on a single-node cluster. A hostPath
140
140
PersistentVolume uses a file or directory on the Node to emulate network-attached storage.
141
141
-->
142
- ## 创建 PersistentVolume
142
+ ## 创建 PersistentVolume {#create-a-pv}
143
143
144
144
在本练习中,你将创建一个 ** hostPath** 类型的 PersistentVolume。
145
145
Kubernetes 支持用于在单节点集群上开发和测试的 hostPath 类型的 PersistentVolume。
@@ -149,7 +149,7 @@ hostPath 类型的 PersistentVolume 使用节点上的文件或目录来模拟
149
149
In a production cluster, you would not use hostPath. Instead a cluster administrator
150
150
would provision a network resource like a Google Compute Engine persistent disk,
151
151
an NFS share, or an Amazon Elastic Block Store volume. Cluster administrators can also
152
- use [StorageClasses](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#storageclass-v1-storage)
152
+ use [StorageClasses](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#storageclass-v1-storage-k8s-io )
153
153
to set up
154
154
[dynamic provisioning](/blog/2016/10/dynamic-provisioning-and-storage-in-kubernetes).
155
155
@@ -158,7 +158,7 @@ Here is the configuration file for the hostPath PersistentVolume:
158
158
在生产集群中,你不会使用 hostPath。
159
159
集群管理员会提供网络存储资源,比如 Google Compute Engine 持久盘卷、NFS 共享卷或 Amazon Elastic Block Store 卷。
160
160
集群管理员还可以使用
161
- [ StorageClasses] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#storageclass-v1-storage)
161
+ [ StorageClasses] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#storageclass-v1-storage-k8s-io )
162
162
来设置[ 动态提供存储] ( /blog/2016/10/dynamic-provisioning-and-storage-in-kubernetes ) 。
163
163
164
164
下面是 hostPath PersistentVolume 的配置文件:
@@ -173,13 +173,12 @@ read-write by a single Node. It defines the [StorageClass name](/docs/concepts/s
173
173
`manual` for the PersistentVolume, which will be used to bind
174
174
PersistentVolumeClaim requests to this PersistentVolume.
175
175
-->
176
- 配置文件指定卷位于集群节点上的 ` /mnt/data ` 路径。
177
- 配置还指定了卷的容量大小为 10 GB,
178
- 访问模式为 ` ReadWriteOnce ` ,
176
+ 此配置文件指定卷位于集群节点上的 ` /mnt/data ` 路径。
177
+ 其配置还指定了卷的容量大小为 10 GB,访问模式为 ` ReadWriteOnce ` ,
179
178
这意味着该卷可以被单个节点以读写方式安装。
180
- 配置文件还在 PersistentVolume 中定义了
181
- [ StorageClass 的名称] ( /zh-cn/docs/concepts/storage/persistent-volumes/#class )
182
- 为 ` manual ` 。 它将用于将 PersistentVolumeClaim 的请求绑定到此 PersistentVolume。
179
+ 此配置文件还在 PersistentVolume 中定义了
180
+ [ StorageClass 的名称] ( /zh-cn/docs/concepts/storage/persistent-volumes/#class ) 为 ` manual ` 。
181
+ 它将用于将 PersistentVolumeClaim 的请求绑定到此 PersistentVolume。
183
182
184
183
<!--
185
184
Create the PersistentVolume:
@@ -203,11 +202,13 @@ kubectl get pv task-pv-volume
203
202
The output shows that the PersistentVolume has a `STATUS` of `Available`. This
204
203
means it has not yet been bound to a PersistentVolumeClaim.
205
204
-->
206
- 输出结果显示该 PersistentVolume 的` 状态(STATUS) ` 为 ` Available ` 。
205
+ 输出结果显示该 PersistentVolume 的` 状态(STATUS) ` 为 ` Available ` 。
207
206
这意味着它还没有被绑定给 PersistentVolumeClaim。
208
207
209
- NAME CAPACITY ACCESSMODES RECLAIMPOLICY STATUS CLAIM STORAGECLASS REASON AGE
210
- task-pv-volume 10Gi RWO Retain Available manual 4s
208
+ ```
209
+ NAME CAPACITY ACCESSMODES RECLAIMPOLICY STATUS CLAIM STORAGECLASS REASON AGE
210
+ task-pv-volume 10Gi RWO Retain Available manual 4s
211
+ ```
211
212
212
213
<!--
213
214
## Create a PersistentVolumeClaim
@@ -219,7 +220,7 @@ access for at least one Node.
219
220
220
221
Here is the configuration file for the PersistentVolumeClaim:
221
222
-->
222
- ## 创建 PersistentVolumeClaim
223
+ ## 创建 PersistentVolumeClaim {#create-a-pvc}
223
224
224
225
下一步是创建一个 PersistentVolumeClaim。
225
226
Pod 使用 PersistentVolumeClaim 来请求物理存储。
@@ -294,11 +295,11 @@ The next step is to create a Pod that uses your PersistentVolumeClaim as a volum
294
295
295
296
Here is the configuration file for the Pod:
296
297
-->
297
- ## 创建 Pod
298
+ ## 创建 Pod {#create-a-pod}
298
299
299
- 下一步是创建一个 Pod, 该 Pod 使用你的 PersistentVolumeClaim 作为存储卷 。
300
+ 下一步是创建一个使用你的 PersistentVolumeClaim 作为存储卷的 Pod。
300
301
301
- 下面是 Pod 的 配置文件 :
302
+ 下面是此 Pod 的配置文件 :
302
303
303
304
{{< codenew file="pods/storage/pv-pod.yaml" >}}
304
305
@@ -340,7 +341,7 @@ kubectl exec -it task-pv-pod -- /bin/bash
340
341
In your shell, verify that nginx is serving the `index.html` file from the
341
342
hostPath volume:
342
343
-->
343
- 在 Shell 中,验证 nginx 是否正在从 hostPath 卷提供 ` index.html ` 文件:
344
+ 在 Shell 中,验证 Nginx 是否正在从 hostPath 卷提供 ` index.html ` 文件:
344
345
345
346
<!--
346
347
# Be sure to run these 3 commands inside the root shell that comes from
@@ -413,7 +414,7 @@ You can now close the shell to your Node.
413
414
<!--
414
415
## Mounting the same persistentVolume in two places
415
416
-->
416
- ## 在两个地方挂载相同的 persistentVolume
417
+ ## 在两个地方挂载相同的 persistentVolume {#mounting-the-same-pv-in-two-places}
417
418
418
419
{{< codenew file="pods/storage/pv-duplicate.yaml" >}}
419
420
@@ -449,6 +450,7 @@ GID 不匹配或缺失将会导致无权访问错误。
449
450
这样 GID 就能自动添加到使用 PersistentVolume 的任何 Pod 中。
450
451
451
452
使用 ` pv.beta.kubernetes.io/gid ` 注解的方法如下所示:
453
+
452
454
``` yaml
453
455
apiVersion : v1
454
456
kind : PersistentVolume
@@ -468,8 +470,7 @@ each container.
468
470
-->
469
471
当 Pod 使用带有 GID 注解的 PersistentVolume 时,注解的 GID 会被应用于 Pod 中的所有容器,
470
472
应用的方法与 Pod 的安全上下文中指定的 GID 相同。
471
- 每个 GID,无论是来自 PersistentVolume 注解还是来自 Pod 规约,都会被应用于每个容器中
472
- 运行的第一个进程。
473
+ 每个 GID,无论是来自 PersistentVolume 注解还是来自 Pod 规约,都会被应用于每个容器中运行的第一个进程。
473
474
474
475
<!--
475
476
When a Pod consumes a PersistentVolume, the GIDs associated with the
0 commit comments