Skip to content

Commit 0ef7e1d

Browse files
authored
Merge pull request #37940 from windsonsea/secrety
[zh] sync /concepts/configuration/secret.md
2 parents 7ea613a + 27c846f commit 0ef7e1d

File tree

1 file changed

+37
-52
lines changed
  • content/zh-cn/docs/concepts/configuration

1 file changed

+37
-52
lines changed

content/zh-cn/docs/concepts/configuration/secret.md

Lines changed: 37 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Kubernetes Secrets are, by default, stored unencrypted in the API server's under
6060
Additionally, anyone who is authorized to create a Pod in a namespace can use that access to read
6161
any Secret in that namespace; this includes indirect access such as the ability to create a
6262
Deployment.
63+
6364
In order to safely use Secrets, take at least the following steps:
6465
6566
1. [Enable Encryption at Rest](/docs/tasks/administer-cluster/encrypt-data/) for Secrets.
@@ -190,17 +191,19 @@ the exact mechanisms for issuing and refreshing those session tokens.
190191
191192
There are several options to create a Secret:
192193
193-
- [create Secret using `kubectl` command](/docs/tasks/configmap-secret/managing-secret-using-kubectl/)
194-
- [create Secret from config file](/docs/tasks/configmap-secret/managing-secret-using-config-file/)
195-
- [create Secret using kustomize](/docs/tasks/configmap-secret/managing-secret-using-kustomize/)
194+
- [Use `kubectl`](/docs/tasks/configmap-secret/managing-secret-using-kubectl/)
195+
- [Use a configuration file](/docs/tasks/configmap-secret/managing-secret-using-config-file/)
196+
- [Use the Kustomize tool](/docs/tasks/configmap-secret/managing-secret-using-kustomize/)
196197
-->
197198
## 使用 Secret {#working-with-secrets}
198199

199200
### 创建 Secret {#creating-a-secret}
200201

201-
- [使用 `kubectl` 命令来创建 Secret](/zh-cn/docs/tasks/configmap-secret/managing-secret-using-kubectl/)
202-
- [基于配置文件来创建 Secret](/zh-cn/docs/tasks/configmap-secret/managing-secret-using-config-file/)
203-
- [使用 kustomize 来创建 Secret](/zh-cn/docs/tasks/configmap-secret/managing-secret-using-kustomize/)
202+
创建 Secret 有以下几种可选方式:
203+
204+
- [使用 `kubectl`](/zh-cn/docs/tasks/configmap-secret/managing-secret-using-kubectl/)
205+
- [使用配置文件](/zh-cn/docs/tasks/configmap-secret/managing-secret-using-config-file/)
206+
- [使用 Kustomize 工具](/zh-cn/docs/tasks/configmap-secret/managing-secret-using-kustomize/)
204207

205208
<!--
206209
#### Constraints on Secret names and data {#restriction-names-data}
@@ -255,56 +258,36 @@ Secret(或其他资源)的个数。
255258
<!--
256259
### Editing a Secret
257260
258-
You can edit an existing Secret using kubectl:
261+
You can edit an existing Secret unless it is [immutable](#secret-immutable). To
262+
edit a Secret, use one of the following methods:
259263
-->
260264
### 编辑 Secret {#editing-a-secret}
261265

262-
你可以使用 kubectl 来编辑一个已有的 Secret:
263-
264-
```shell
265-
kubectl edit secrets mysecret
266-
```
266+
你可以编辑一个已有的 Secret,除非它是[不可变更的](#secret-immutable)
267+
要编辑一个 Secret,可使用以下方法之一:
267268

268269
<!--
269-
This opens your default editor and allows you to update the base64 encoded Secret
270-
values in the `data` field; for example:
270+
* [Use `kubectl`](/docs/tasks/configmap-secret/managing-secret-using-kubectl/#edit-secret)
271+
* [Use a configuration file](/docs/tasks/configmap-secret/managing-secret-using-config-file/#edit-secret)
271272
-->
272-
这一命令会启动你的默认编辑器,允许你更新 `data` 字段中存放的 base64 编码的 Secret 值;
273-
例如:
274-
275-
```yaml
276-
# 请编辑以下对象。以 `#` 开头的几行将被忽略,
277-
# 且空文件将放弃编辑。如果保存此文件时出错,
278-
# 则重新打开此文件时也会有相关故障。
279-
apiVersion: v1
280-
data:
281-
username: YWRtaW4=
282-
password: MWYyZDFlMmU2N2Rm
283-
kind: Secret
284-
metadata:
285-
annotations:
286-
kubectl.kubernetes.io/last-applied-configuration: { ... }
287-
creationTimestamp: 2020-01-22T18:41:56Z
288-
name: mysecret
289-
namespace: default
290-
resourceVersion: "164619"
291-
uid: cfee02d6-c137-11e5-8d73-42010af00002
292-
type: Opaque
293-
```
273+
* [使用 `kubectl`](/zh-cn/docs/tasks/configmap-secret/managing-secret-using-kubectl/#edit-secret)
274+
* [使用配置文件](/zh-cn/docs/tasks/configmap-secret/managing-secret-using-config-file/#edit-secret)
294275

295276
<!--
296-
That example manifest defines a Secret with two keys in the `data` field: `username` and `password`.
297-
The values are Base64 strings in the manifest; however, when you use the Secret with a Pod
298-
then the kubelet provides the _decoded_ data to the Pod and its containers.
277+
You can also edit the data in a Secret using the [Kustomize tool](/docs/tasks/configmap-secret/managing-secret-using-kustomize/#edit-secret). However, this
278+
method creates a new `Secret` object with the edited data.
299279
300-
You can package many keys and values into one Secret, or use many Secrets, whichever is convenient.
280+
Depending on how you created the Secret, as well as how the Secret is used in
281+
your Pods, updates to existing `Secret` objects are propagated automatically to
282+
Pods that use the data. For more information, refer to [Mounted Secrets are updated automatically](#mounted-secrets-are-updated-automatically).
301283
-->
302-
这一示例清单定义了一个 Secret,其 `data` 字段中包含两个主键:`username` 和 `password`。
303-
清单中的字段值是 Base64 字符串,不过,当你在 Pod 中使用 Secret 时,kubelet 为 Pod
304-
及其中的容器提供的是**解码**后的数据
284+
你也可以使用
285+
[Kustomize 工具](/zh-cn/docs/tasks/configmap-secret/managing-secret-using-kustomize/#edit-secret)编辑数据。
286+
然而这种方法会用编辑过的数据创建新的 `Secret` 对象
305287

306-
你可以在一个 Secret 中打包多个主键和数值,也可以选择使用多个 Secret,
307-
完全取决于哪种方式最方便。
288+
根据你创建 Secret 的方式以及该 Secret 在 Pod 中被使用的方式,对已有 `Secret`
289+
对象的更新将自动扩散到使用此数据的 Pod。有关更多信息,
290+
请参阅[自动更新挂载的 Secret](#mounted-secrets-are-updated-automatically)
308291

309292
<!--
310293
### Using a Secret
@@ -706,8 +689,8 @@ in a Pod:
706689
-->
707690
### 以环境变量的方式使用 Secret {#using-secrets-as-environment-variables}
708691

709-
如果需要在 Pod 中以{{< glossary_tooltip text="环境变量" term_id="container-env-variables" >}}
710-
的形式使用 Secret:
692+
如果需要在 Pod
693+
中以{{< glossary_tooltip text="环境变量" term_id="container-env-variables" >}}的形式使用 Secret:
711694

712695
<!--
713696
1. Create a Secret (or use an existing one). Multiple Pods can reference the same Secret.
@@ -865,7 +848,7 @@ The `imagePullSecrets` field for a Pod is a list of references to Secrets in the
865848
as the Pod.
866849
You can use an `imagePullSecrets` to pass image registry access credentials to
867850
the kubelet. The kubelet uses this information to pull a private image on behalf of your Pod.
868-
See the [PodSpec API](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podspec-v1-core)
851+
See `PodSpec` in the [Pod API reference](/docs/reference/kubernetes-api/workload-resources/pod-v1/#PodSpec)
869852
for more information about the `imagePullSecrets` field.
870853
-->
871854
Pod 的 `imagePullSecrets` 字段是一个对 Pod 所在的名字空间中的 Secret
@@ -880,7 +863,8 @@ kubelet 使用这个信息来替你的 Pod 拉取私有镜像。
880863
The `imagePullSecrets` field is a list of references to secrets in the same namespace.
881864
You can use an `imagePullSecrets` to pass a secret that contains a Docker (or other) image registry
882865
password to the kubelet. The kubelet uses this information to pull a private image on behalf of your Pod.
883-
See the [PodSpec API](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podspec-v1-core) for more information about the `imagePullSecrets` field.
866+
See the [PodSpec API](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podspec-v1-core)
867+
for more information about the `imagePullSecrets` field.
884868
-->
885869
#### 使用 imagePullSecrets {#using-imagepullsecrets-1}
886870

@@ -1137,6 +1121,7 @@ For example, if your actual password is `S!B\*d$zDsb=`, you should execute the c
11371121
```shell
11381122
kubectl create secret generic dev-db-secret --from-literal=username=devuser --from-literal=password='S!B\*d$zDsb='
11391123
```
1124+
11401125
<!--
11411126
You do not need to escape special characters in passwords from files (`--from-file`).
11421127
-->
@@ -1949,7 +1934,7 @@ A bootstrap type Secret has the following keys specified under `data`:
19491934
- `token-secret`: A random 16 character string as the actual token secret. Required.
19501935
- `description`: A human-readable string that describes what the token is
19511936
used for. Optional.
1952-
- `expiration`: An absolute UTC time using RFC3339 specifying when the token
1937+
- `expiration`: An absolute UTC time using [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339) specifying when the token
19531938
should be expired. Optional.
19541939
- `usage-bootstrap-<usage>`: A boolean flag indicating additional usage for
19551940
the bootstrap token.
@@ -1961,7 +1946,8 @@ A bootstrap type Secret has the following keys specified under `data`:
19611946
- `token-id`:由 6 个随机字符组成的字符串,作为令牌的标识符。必需。
19621947
- `token-secret`:由 16 个随机字符组成的字符串,包含实际的令牌机密。必需。
19631948
- `description`:供用户阅读的字符串,描述令牌的用途。可选。
1964-
- `expiration`:一个使用 RFC3339 来编码的 UTC 绝对时间,给出令牌要过期的时间。可选。
1949+
- `expiration`:一个使用 [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339)
1950+
来编码的 UTC 绝对时间,给出令牌要过期的时间。可选。
19651951
- `usage-bootstrap-<usage>`:布尔类型的标志,用来标明启动引导令牌的其他用途。
19661952
- `auth-extra-groups`:用逗号分隔的组名列表,身份认证时除被认证为
19671953
`system:bootstrappers` 组之外,还会被添加到所列的用户组中。
@@ -2148,7 +2134,6 @@ Secrets used on that node.
21482134
- Learn how to [manage Secrets using kustomize](/docs/tasks/configmap-secret/managing-secret-using-kustomize/)
21492135
- Read the [API reference](/docs/reference/kubernetes-api/config-and-storage-resources/secret-v1/) for `Secret`
21502136
-->
2151-
21522137
- 有关管理和提升 Secret 安全性的指南,请参阅 [Kubernetes Secret 良好实践](/zh-cn/docs/concepts/security/secrets-good-practices)
21532138
- 学习如何[使用 `kubectl` 管理 Secret](/zh-cn/docs/tasks/configmap-secret/managing-secret-using-kubectl/)
21542139
- 学习如何[使用配置文件管理 Secret](/zh-cn/docs/tasks/configmap-secret/managing-secret-using-config-file/)

0 commit comments

Comments
 (0)