Skip to content

Commit 283ed01

Browse files
authored
Merge pull request #35419 from yanrongshi/zh-cn]update-content-en-docs-tasks-inject-data-application-distribute-credentials-secure.md
[zh-cn]Update distribute-credentials-secure.md
2 parents 6a69ea9 + bb0d7af commit 283ed01

File tree

1 file changed

+34
-21
lines changed

1 file changed

+34
-21
lines changed

content/zh-cn/docs/tasks/inject-data-application/distribute-credentials-secure.md

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ encryption keys, into Pods.
1212
-->
1313
本文展示如何安全地将敏感数据(如密码和加密密钥)注入到 Pods 中。
1414

15+
1516
## {{% heading "prerequisites" %}}
1617

18+
1719
{{< include "task-tutorial-prereqs.md" >}}
1820

1921

@@ -69,8 +71,10 @@ username and password:
6971
kubectl apply -f https://k8s.io/examples/pods/inject/secret.yaml
7072
```
7173

72-
1. <!-- View information about the Secret -->
73-
查看 Secret 相关信息:
74+
<!--
75+
1. View information about the Secret:
76+
-->
77+
2. 查看 Secret 相关信息:
7478

7579
```shell
7680
kubectl get secret test-secret
@@ -79,12 +83,12 @@ username and password:
7983
<!-- Output: -->
8084
输出:
8185

82-
```shell
86+
```
8387
NAME TYPE DATA AGE
8488
test-secret Opaque 2 1m
8589
```
8690

87-
1. <!-- View more detailed information about the Secret -->
91+
1. <!-- View more detailed information about the Secret:-->
8892
查看 Secret 相关的更多详细信息:
8993

9094
```shell
@@ -94,7 +98,7 @@ username and password:
9498
<!-- Output: -->
9599
输出:
96100

97-
```shell
101+
```
98102
Name: test-secret
99103
Namespace: default
100104
Labels: <none>
@@ -105,7 +109,7 @@ username and password:
105109
Data
106110
====
107111
password: 13 bytes
108-
username: 7 bytes
112+
username: 7 bytes
109113
```
110114

111115
<!--
@@ -130,6 +134,7 @@ through each step explicitly to demonstrate what is happening.
130134
这是一种更为方便的方法。
131135
前面展示的详细分解步骤有助于了解究竟发生了什么事情。
132136

137+
133138
<!--
134139
## Create a Pod that has access to the secret data through a Volume
135140
@@ -145,7 +150,7 @@ Here is a configuration file you can use to create a Pod:
145150
创建 Pod:
146151

147152
```shell
148-
kubectl create -f secret-pod.yaml
153+
kubectl apply -f https://k8s.io/examples/pods/inject/secret-pod.yaml
149154
```
150155

151156
1. <!-- Verify that your Pod is running: -->
@@ -155,9 +160,9 @@ Here is a configuration file you can use to create a Pod:
155160
kubectl get pod secret-test-pod
156161
```
157162

163+
<!-- Output: -->
158164
输出:
159-
160-
```shell
165+
```
161166
NAME READY STATUS RESTARTS AGE
162167
secret-test-pod 1/1 Running 0 42m
163168
```
@@ -166,7 +171,7 @@ Here is a configuration file you can use to create a Pod:
166171
获取一个 shell 进入 Pod 中运行的容器:
167172

168173
```shell
169-
kubectl exec -it secret-test-pod -- /bin/bash
174+
kubectl exec -i -t secret-test-pod -- /bin/bash
170175
```
171176

172177
1. <!-- The secret data is exposed to the Container through a Volume mounted under
@@ -179,6 +184,7 @@ Here is a configuration file you can use to create a Pod:
179184
在 shell 中,列举 `/etc/secret-volume` 目录下的文件:
180185

181186
```shell
187+
# 在容器中 Shell 运行下面命令
182188
ls /etc/secret-volume
183189
```
184190

@@ -195,19 +201,18 @@ Here is a configuration file you can use to create a Pod:
195201
In your shell, display the contents of the `username` and `password` files:
196202
-->
197203
在 Shell 中,显示 `username``password` 文件的内容:
198-
199204
```shell
200205
# 在容器中 Shell 运行下面命令
201-
echo "$(cat /etc/secret-volume/username)"
202-
echo "$(cat /etc/secret-volume/password)"
206+
echo "$( cat /etc/secret-volume/username )"
207+
echo "$( cat /etc/secret-volume/password )"
203208
```
204209

205210
<!--
206211
The output is your username and password:
207212
-->
208213
输出为用户名和密码:
209214

210-
```shell
215+
```
211216
my-app
212217
39528$vdg7Jb
213218
```
@@ -256,11 +261,14 @@ Here is a configuration file you can use to create a Pod:
256261
kubectl exec -i -t env-single-secret -- /bin/sh -c 'echo $SECRET_USERNAME'
257262
```
258263

264+
<!--
265+
The output is
266+
-->
259267
输出为:
260-
261268
```
262269
backend-admin
263270
```
271+
264272
<!--
265273
### Define container environment variables with data from multiple Secrets
266274
-->
@@ -300,13 +308,16 @@ Here is a configuration file you can use to create a Pod:
300308
```shell
301309
kubectl exec -i -t envvars-multiple-secrets -- /bin/sh -c 'env | grep _USERNAME'
302310
```
303-
311+
<!--
312+
The output is
313+
-->
304314
输出:
305315
```
306316
DB_USERNAME=db-admin
307317
BACKEND_USERNAME=backend-admin
308318
```
309319

320+
310321
<!--
311322
## Configure all key-value pairs in a Secret as container environment variables
312323
-->
@@ -353,7 +364,10 @@ This functionality is available in Kubernetes v1.6 and later.
353364
```shell
354365
kubectl exec -i -t envfrom-secret -- /bin/sh -c 'echo "username: $username\npassword: $password\n"'
355366
```
356-
367+
368+
<!--
369+
The output is
370+
-->
357371
输出为:
358372

359373
```
@@ -364,10 +378,9 @@ This functionality is available in Kubernetes v1.6 and later.
364378
<!-- ### References -->
365379
### 参考
366380

367-
* [Secret](/docs/api-reference/{{< param "version" >}}/#secret-v1-core)
368-
* [Volume](/docs/api-reference/{{< param "version" >}}/#volume-v1-core)
369-
* [Pod](/docs/api-reference/{{< param "version" >}}/#pod-v1-core)
370-
381+
* [Secret](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#secret-v1-core)
382+
* [Volume](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#volume-v1-core)
383+
* [Pod](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#pod-v1-core)
371384

372385
## {{% heading "whatsnext" %}}
373386

0 commit comments

Comments
 (0)