Skip to content

Commit 550f3e5

Browse files
authored
Merge pull request #35311 from yanrongshi/zh-cn]sync-managing-secret-using-config-file
[zh-cn]sync managing-secret-using-config-file.md
2 parents 36c48a7 + 86b4266 commit 550f3e5

File tree

1 file changed

+51
-21
lines changed

1 file changed

+51
-21
lines changed

content/zh-cn/docs/tasks/configmap-secret/managing-secret-using-config-file.md

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ description: Creating Secret objects using resource configuration file.
1919

2020
<!-- steps -->
2121

22-
<!-- ## Create the Config file -->
22+
<!--
23+
##Create the Config file
24+
-->
2325
## 创建配置文件 {#create-the-config-file}
2426

25-
<!--
27+
<!--
2628
You can create a Secret in a file first, in JSON or YAML format, and then
2729
create that object. The
2830
[Secret](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#secret-v1-core)
@@ -40,7 +42,7 @@ The keys of `data` and `stringData` must consist of alphanumeric characters,
4042
提供 `stringData` 字段是为了方便,它允许 Secret 使用未编码的字符串。
4143
`data``stringData` 的键必须由字母、数字、`-``_``.` 组成。
4244

43-
<!--
45+
<!--
4446
For example, to store two strings in a Secret using the `data` field, convert
4547
the strings to base64 as follows:
4648
-->
@@ -50,7 +52,9 @@ the strings to base64 as follows:
5052
echo -n 'admin' | base64
5153
```
5254

53-
<!-- The output is similar to: -->
55+
<!--
56+
The output is similar to:
57+
-->
5458
输出类似于:
5559

5660
```
@@ -61,14 +65,18 @@ YWRtaW4=
6165
echo -n '1f2d1e2e67df' | base64
6266
```
6367

64-
<!-- The output is similar to: -->
68+
<!--
69+
The output is similar to:
70+
-->
6571
输出类似于:
6672

6773
```
6874
MWYyZDFlMmU2N2Rm
6975
```
7076

71-
<!-- Write a Secret config file that looks like this: -->
77+
<!--
78+
Write a Secret config file that looks like this:
79+
-->
7280
编写一个 Secret 配置文件,如下所示:
7381

7482
```yaml
@@ -86,7 +94,7 @@ data:
8694
Note that the name of a Secret object must be a valid
8795
[DNS subdomain name](/docs/concepts/overview/working-with-objects/names#dns-subdomain-names).
8896
-->
89-
注意,Secret 对象的名称必须是有效的 [DNS 子域名](/zh-cn/docs/concepts/overview/working-with-objects/names#dns-subdomain-names).
97+
注意,Secret 对象的名称必须是有效的 [DNS 子域名](/zh-cn/docs/concepts/overview/working-with-objects/names#dns-subdomain-names)
9098
9199
{{< note >}}
92100
<!--
@@ -100,7 +108,7 @@ option is not available.
100108
Secret 数据的 JSON 和 YAML 序列化结果是以 base64 编码的。
101109
换行符在这些字符串中无效,必须省略。
102110
在 Darwin/macOS 上使用 `base64` 工具时,用户不应该使用 `-b` 选项分割长行。
103-
相反地,Linux 用户 *应该* 在 `base64` 地命令中添加 `-w 0` 选项,
111+
相反地,Linux 用户**应该**在 `base64` 地命令中添加 `-w 0` 选项,
104112
或者在 `-w` 选项不可用的情况下,输入 `base64 | tr -d '\n'`。
105113
{{< /note >}}
106114

@@ -110,7 +118,7 @@ field allows you to put a non-base64 encoded string directly into the Secret,
110118
and the string will be encoded for you when the Secret is created or updated.
111119
-->
112120
对于某些场景,你可能希望使用 `stringData` 字段。
113-
这字段可以将一个非 base64 编码的字符串直接放入 Secret 中,
121+
这个字段可以将一个非 base64 编码的字符串直接放入 Secret 中,
114122
当创建或更新该 Secret 时,此字段将被编码。
115123

116124
<!--
@@ -121,7 +129,9 @@ parts of that configuration file during your deployment process.
121129
上述用例的实际场景可能是这样:当你部署应用时,使用 Secret 存储配置文件,
122130
你希望在部署过程中,填入部分内容到该配置文件。
123131

124-
<!-- For example, if your application uses the following configuration file: -->
132+
<!--
133+
or example, if your application uses the following configuration file:
134+
-->
125135
例如,如果你的应用程序使用以下配置文件:
126136

127137
```yaml
@@ -130,7 +140,9 @@ username: "<user>"
130140
password: "<password>"
131141
```
132142

133-
<!-- You could store this in a Secret using the following definition: -->
143+
<!--
144+
You could store this in a Secret using the following definition:
145+
-->
134146
你可以使用以下定义将其存储在 Secret 中:
135147

136148
```yaml
@@ -146,24 +158,32 @@ stringData:
146158
password: <password>
147159
```
148160

149-
<!-- ## Create the Secret object -->
161+
<!--
162+
## Create the Secret object
163+
-->
150164
## 创建 Secret 对象 {#create-the-secret-object}
151165

152-
<!-- Now create the Secret using [`kubectl apply`](/docs/reference/generated/kubectl/kubectl-commands#apply): -->
166+
<!--
167+
Now create the Secret using [`kubectl apply`](/docs/reference/generated/kubectl/kubectl-commands#apply):
168+
-->
153169
现在使用 [`kubectl apply`](/docs/reference/generated/kubectl/kubectl-commands#apply) 创建 Secret:
154170

155171
```shell
156172
kubectl apply -f ./secret.yaml
157173
```
158174

159-
<!-- The output is similar to: -->
175+
<!--
176+
The output is similar to:
177+
-->
160178
输出类似于:
161179

162180
```
163181
secret/mysecret created
164182
```
165183
166-
<!-- ## Check the Secret -->
184+
<!--
185+
## Check the Secret
186+
-->
167187
## 检查 Secret {#check-the-secret}
168188
169189
<!--
@@ -178,7 +198,9 @@ retrieving Secrets. For example, if you run the following command:
178198
kubectl get secret mysecret -o yaml
179199
```
180200

181-
<!-- The output is similar to: -->
201+
<!--
202+
The output is similar to:
203+
-->
182204
输出类似于:
183205

184206
```yaml
@@ -204,7 +226,7 @@ To check the actual content of the encoded data, please refer to
204226
-->
205227
命令 `kubectl get` 和 `kubectl describe` 默认不显示 `Secret` 的内容。
206228
这是为了防止 `Secret` 意外地暴露给旁观者或者保存在终端日志中。
207-
检查编码数据的实际内容,请参考[解码 secret](/zh-cn/docs/tasks/configmap-secret/managing-secret-using-kubectl/#decoding-secret).
229+
检查编码数据的实际内容,请参考[解码 secret](/zh-cn/docs/tasks/configmap-secret/managing-secret-using-kubectl/#decoding-secret)
208230

209231
<!--
210232
If a field, such as `username`, is specified in both `data` and `stringData`,
@@ -225,7 +247,9 @@ stringData:
225247
username: administrator
226248
```
227249

228-
<!-- Results in the following Secret: -->
250+
<!--
251+
Results in the following Secret:
252+
-->
229253
结果有以下 Secret:
230254

231255
```yaml
@@ -242,13 +266,19 @@ metadata:
242266
type: Opaque
243267
```
244268

245-
<!-- Where `YWRtaW5pc3RyYXRvcg==` decodes to `administrator`. -->
269+
<!--
270+
Where `YWRtaW5pc3RyYXRvcg==` decodes to `administrator`.
271+
-->
246272
其中 `YWRtaW5pc3RyYXRvcg==` 解码成 `administrator`。
247273

248-
<!-- ## Clean Up -->
274+
<!--
275+
## Clean Up
276+
-->
249277
## 清理 {#clean-up}
250278

251-
<!-- To delete the Secret you have created: -->
279+
<!--
280+
To delete the Secret you have created:
281+
-->
252282
删除你创建的 Secret:
253283

254284
```shell

0 commit comments

Comments
 (0)