1
1
---
2
2
title : 配置 Pod 以使用 PersistentVolume 作为存储
3
3
content_type : task
4
- weight : 60
4
+ weight : 90
5
5
---
6
-
7
6
<!--
8
7
title: Configure a Pod to Use a PersistentVolume for Storage
9
8
content_type: task
10
- weight: 60
9
+ weight: 90
11
10
-->
12
11
13
12
<!-- overview -->
@@ -19,11 +18,11 @@ for storage.
19
18
Here is a summary of the process:
20
19
21
20
1. You, as cluster administrator, create a PersistentVolume backed by physical
22
- storage. You do not associate the volume with any Pod.
21
+ storage. You do not associate the volume with any Pod.
23
22
24
23
1. You, now taking the role of a developer / cluster user, create a
25
- PersistentVolumeClaim that is automatically bound to a suitable
26
- PersistentVolume.
24
+ PersistentVolumeClaim that is automatically bound to a suitable
25
+ PersistentVolume.
27
26
28
27
1. You create a Pod that uses the above PersistentVolumeClaim for storage.
29
28
-->
@@ -43,15 +42,14 @@ PersistentVolume.
43
42
44
43
<!--
45
44
* You need to have a Kubernetes cluster that has only one Node, and the
46
- {{< glossary_tooltip text="kubectl" term_id="kubectl" >}}
47
- command-line tool must be configured to communicate with your cluster. If you
48
- do not already have a single-node cluster, you can create one by using
49
- [Minikube](https://minikube.sigs.k8s.io/docs/).
45
+ {{< glossary_tooltip text="kubectl" term_id="kubectl" >}}
46
+ command-line tool must be configured to communicate with your cluster. If you
47
+ do not already have a single-node cluster, you can create one by using
48
+ [Minikube](https://minikube.sigs.k8s.io/docs/).
50
49
51
50
* Familiarize yourself with the material in
52
- [Persistent Volumes](/docs/concepts/storage/persistent-volumes/).
51
+ [Persistent Volumes](/docs/concepts/storage/persistent-volumes/).
53
52
-->
54
-
55
53
* 你需要一个包含单个节点的 Kubernetes 集群,并且必须配置
56
54
{{< glossary_tooltip text="kubectl" term_id="kubectl" >}} 命令行工具以便与集群交互。
57
55
如果还没有单节点集群,可以使用
@@ -101,11 +99,11 @@ In the `/mnt/data` directory, create an `index.html` file:
101
99
sudo sh -c " echo 'Hello from Kubernetes storage' > /mnt/data/index.html"
102
100
```
103
101
102
+ {{< note >}}
104
103
<!--
105
104
If your Node uses a tool for superuser access other than `sudo`, you can
106
105
usually make this work if you replace `sudo` with the name of the other tool.
107
106
-->
108
- {{< note >}}
109
107
如果你的节点使用某工具而不是 ` sudo ` 来完成超级用户访问,你可以将上述命令中的 ` sudo ` 替换为该工具的名称。
110
108
{{< /note >}}
111
109
@@ -374,7 +372,7 @@ use storage from a PersistentVolumeClaim.
374
372
<!--
375
373
## Clean up
376
374
377
- Delete the Pod, the PersistentVolumeClaim and the PersistentVolume:
375
+ Delete the Pod, the PersistentVolumeClaim and the PersistentVolume:
378
376
-->
379
377
## 清理 {#clean-up}
380
378
@@ -395,11 +393,11 @@ In the shell on your Node, remove the file and directory that you created:
395
393
如果你还没有连接到集群中节点的 Shell,可以按之前所做操作,打开一个新的 Shell。
396
394
397
395
在节点的 Shell 上,删除你所创建的目录和文件:
396
+
398
397
<!--
399
398
# This assumes that your Node uses "sudo" to run commands
400
399
# as the superuser
401
400
-->
402
-
403
401
``` shell
404
402
# 这里假定你使用 "sudo" 来以超级用户的角色执行命令
405
403
sudo rm /mnt/data/index.html
@@ -426,8 +424,8 @@ You can perform 2 volume mounts on your nginx container:
426
424
-->
427
425
你可以在 nginx 容器上执行两个卷挂载:
428
426
429
- ` /usr/share/nginx/html ` 用于静态网站
430
- ` /etc/nginx/nginx.conf ` 作为默认配置
427
+ - ` /usr/share/nginx/html ` 用于静态网站
428
+ - ` /etc/nginx/nginx.conf ` 作为默认配置
431
429
432
430
<!-- discussion -->
433
431
@@ -472,11 +470,11 @@ each container.
472
470
应用的方法与 Pod 的安全上下文中指定的 GID 相同。
473
471
每个 GID,无论是来自 PersistentVolume 注解还是来自 Pod 规约,都会被应用于每个容器中运行的第一个进程。
474
472
473
+ {{< note >}}
475
474
<!--
476
475
When a Pod consumes a PersistentVolume, the GIDs associated with the
477
476
PersistentVolume are not present on the Pod resource itself.
478
477
-->
479
- {{< note >}}
480
478
当 Pod 使用 PersistentVolume 时,与 PersistentVolume 关联的 GID 不会在 Pod
481
479
资源本身的对象上出现。
482
480
{{< /note >}}
@@ -493,7 +491,7 @@ PersistentVolume are not present on the Pod resource itself.
493
491
<!--
494
492
### Reference
495
493
-->
496
- ### 参考
494
+ ### 参考 {#reference}
497
495
498
496
* [PersistentVolume](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#persistentvolume-v1-core)
499
497
* [PersistentVolumeSpec](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#persistentvolumespec-v1-core)
0 commit comments