diff --git a/content/zh-cn/docs/tasks/inject-data-application/distribute-credentials-secure.md b/content/zh-cn/docs/tasks/inject-data-application/distribute-credentials-secure.md index 5ede095df1..0a07cf1094 100644 --- a/content/zh-cn/docs/tasks/inject-data-application/distribute-credentials-secure.md +++ b/content/zh-cn/docs/tasks/inject-data-application/distribute-credentials-secure.md @@ -12,8 +12,10 @@ encryption keys, into Pods. --> 本文展示如何安全地将敏感数据(如密码和加密密钥)注入到 Pods 中。 + ## {{% heading "prerequisites" %}} + {{< include "task-tutorial-prereqs.md" >}} @@ -69,8 +71,10 @@ username and password: kubectl apply -f https://k8s.io/examples/pods/inject/secret.yaml ``` -1. - 查看 Secret 相关信息: + +2. 查看 Secret 相关信息: ```shell kubectl get secret test-secret @@ -79,12 +83,12 @@ username and password: 输出: - ```shell + ``` NAME TYPE DATA AGE test-secret Opaque 2 1m ``` -1. +1. 查看 Secret 相关的更多详细信息: ```shell @@ -94,7 +98,7 @@ username and password: 输出: - ```shell + ``` Name: test-secret Namespace: default Labels: @@ -105,7 +109,7 @@ username and password: Data ==== password: 13 bytes - username: 7 bytes + username: 7 bytes ``` @@ -155,9 +160,9 @@ Here is a configuration file you can use to create a Pod: kubectl get pod secret-test-pod ``` + 输出: - - ```shell + ``` NAME READY STATUS RESTARTS AGE secret-test-pod 1/1 Running 0 42m ``` @@ -166,7 +171,7 @@ Here is a configuration file you can use to create a Pod: 获取一个 shell 进入 Pod 中运行的容器: ```shell - kubectl exec -it secret-test-pod -- /bin/bash + kubectl exec -i -t secret-test-pod -- /bin/bash ``` 1. 在 Shell 中,显示 `username` 和 `password` 文件的内容: - ```shell # 在容器中 Shell 运行下面命令 - echo "$(cat /etc/secret-volume/username)" - echo "$(cat /etc/secret-volume/password)" + echo "$( cat /etc/secret-volume/username )" + echo "$( cat /etc/secret-volume/password )" ``` 输出为用户名和密码: - ```shell + ``` my-app 39528$vdg7Jb ``` @@ -256,11 +261,14 @@ Here is a configuration file you can use to create a Pod: kubectl exec -i -t env-single-secret -- /bin/sh -c 'echo $SECRET_USERNAME' ``` + 输出为: - ``` backend-admin ``` + @@ -300,13 +308,16 @@ Here is a configuration file you can use to create a Pod: ```shell kubectl exec -i -t envvars-multiple-secrets -- /bin/sh -c 'env | grep _USERNAME' ``` - + 输出: ``` DB_USERNAME=db-admin BACKEND_USERNAME=backend-admin ``` + @@ -353,7 +364,10 @@ This functionality is available in Kubernetes v1.6 and later. ```shell kubectl exec -i -t envfrom-secret -- /bin/sh -c 'echo "username: $username\npassword: $password\n"' ``` - + + 输出为: ``` @@ -364,10 +378,9 @@ This functionality is available in Kubernetes v1.6 and later. ### 参考 -* [Secret](/docs/api-reference/{{< param "version" >}}/#secret-v1-core) -* [Volume](/docs/api-reference/{{< param "version" >}}/#volume-v1-core) -* [Pod](/docs/api-reference/{{< param "version" >}}/#pod-v1-core) - +* [Secret](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#secret-v1-core) +* [Volume](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#volume-v1-core) +* [Pod](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#pod-v1-core) ## {{% heading "whatsnext" %}}