diff --git a/content/zh/docs/tasks/configure-pod-container/configure-projected-volume-storage.md b/content/zh/docs/tasks/configure-pod-container/configure-projected-volume-storage.md new file mode 100644 index 0000000000..ec892fe01e --- /dev/null +++ b/content/zh/docs/tasks/configure-pod-container/configure-projected-volume-storage.md @@ -0,0 +1,110 @@ +--- +reviewers: +- jpeeler +- pmorie +title: 配置 Pod 使用投射卷作存储 +content_template: templates/task +weight: 70 +--- + + + +{{% capture overview %}} + + +本文介绍怎样通过[`投射`](/docs/concepts/storage/volumes/#projected) 卷将现有的多个卷资源挂载到相同的目录。 +当前,`secret`、`configMap`、`downwardAPI` 和 `serviceAccountToken` 卷可以被投射。 + +{{< note >}} + +`serviceAccountToken` 不是一种卷类型 +{{< /note >}} +{{% /capture %}} + +{{% capture prerequisites %}} +{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}} +{{% /capture %}} + +{{% capture steps %}} + + + +## 为 Pod 配置投射卷 + +本练习中,您将从本地文件来创建包含有用户名和密码的 Secret。然后创建运行一个容器的 Pod,该 Pod 使用[`投射`](/docs/concepts/storage/volumes/#projected) 卷将 Secret 挂载到相同的路径下。 + +下面是 Pod 的配置文件: + +{{< codenew file="pods/storage/projected.yaml" >}} + +1. 创建 Secrets: +```shell + # 创建包含用户名和密码的文件: + echo -n "admin" > ./username.txt + echo -n "1f2d1e2e67df" > ./password.txt--> + + # 将上述文件引用到 Secret: + kubectl create secret generic user --from-file=./username.txt + kubectl create secret generic pass --from-file=./password.txt +``` + +1. 创建 Pod: + +```shell + kubectl create -f https://k8s.io/examples/pods/storage/projected.yaml +``` + +确认 Pod 中的容器运行正常,然后监视 Pod 的变化: + +```shell + kubectl get --watch pod test-projected-volume +``` + + 输出结果和下面类似: + NAME READY STATUS RESTARTS AGE + test-projected-volume 1/1 Running 0 14s + +1. 在另外一个终端中,打开容器的 shell: +```shell + kubectl exec -it test-projected-volume -- /bin/sh +``` + +1. 在 shell 中,确认 `projected-volume` 目录包含你的投射源: +```shell + ls /projected-volume/ +``` +{{% /capture %}} + +{{% capture whatsnext %}} + + + +* 进一步了解[`投射`](/docs/concepts/storage/volumes/#projected) 卷。 +* 阅读[一体卷](https://github.com/kubernetes/community/blob/{{< param "githubbranch" >}}/contributors/design-proposals/node/all-in-one-volume.md)设计文档。 +{{% /capture %}} +