Skip to content

Commit 18bf2af

Browse files
authored
Merge pull request #37231 from liangyongzhenya/sync/secretzh
[zh] sync/docs/concepts/configuration/secret.md
2 parents 19dbafc + e0aec78 commit 18bf2af

File tree

1 file changed

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

1 file changed

+37
-30
lines changed

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

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,16 @@ Secret 类似于 {{<glossary_tooltip text="ConfigMap" term_id="configmap" >}}
5555

5656
{{< caution >}}
5757
<!--
58-
Kubernetes Secrets are, by default, stored unencrypted in the API server's underlying data store (etcd). Anyone with API access can retrieve or modify a Secret, and so can anyone with access to etcd.
59-
Additionally, anyone who is authorized to create a Pod in a namespace can use that access to read any Secret in that namespace; this includes indirect access such as the ability to create a Deployment.
60-
58+
Kubernetes Secrets are, by default, stored unencrypted in the API server's underlying data store
59+
(etcd). Anyone with API access can retrieve or modify a Secret, and so can anyone with access to etcd.
60+
Additionally, anyone who is authorized to create a Pod in a namespace can use that access to read
61+
any Secret in that namespace; this includes indirect access such as the ability to create a
62+
Deployment.
6163
In order to safely use Secrets, take at least the following steps:
6264
6365
1. [Enable Encryption at Rest](/docs/tasks/administer-cluster/encrypt-data/) for Secrets.
64-
1. [Enable or configure RBAC rules](/docs/reference/access-authn-authz/authorization/) with least-privilege access to Secrets.
66+
1. [Enable or configure RBAC rules](/docs/reference/access-authn-authz/authorization/) with
67+
least-privilege access to Secrets.
6568
1. Restrict Secret access to specific containers.
6669
1. [Consider using external Secret store providers](https://secrets-store-csi-driver.sigs.k8s.io/concepts.html#provider-for-the-secrets-store-csi-driver).
6770
-->
@@ -377,10 +380,14 @@ To configure that, you:
377380

378381
<!--
379382
1. Create a secret or use an existing one. Multiple Pods can reference the same secret.
380-
1. Modify your Pod definition to add a volume under `.spec.volumes[]`. Name the volume anything, and have a `.spec.volumes[].secret.secretName` field equal to the name of the Secret object.
381-
1. Add a `.spec.containers[].volumeMounts[]` to each container that needs the secret. Specify `.spec.containers[].volumeMounts[].readOnly = true` and `.spec.containers[].volumeMounts[].mountPath` to an unused directory name where you would like the secrets to appear.
382-
1. Modify your image or command line so that the program looks for files in that directory. Each key in the secret `data` map becomes the filename under `mountPath`.
383-
383+
1. Modify your Pod definition to add a volume under `.spec.volumes[]`. Name the volume anything,
384+
and have a `.spec.volumes[].secret.secretName` field equal to the name of the Secret object.
385+
1. Add a `.spec.containers[].volumeMounts[]` to each container that needs the secret. Specify
386+
`.spec.containers[].volumeMounts[].readOnly = true` and
387+
`.spec.containers[].volumeMounts[].mountPath` to an unused directory name where you would like the
388+
secrets to appear.
389+
1. Modify your image or command line so that the program looks for files in that directory. Each
390+
key in the secret `data` map becomes the filename under `mountPath`.
384391
This is an example of a Pod that mounts a Secret named `mysecret` in a volume:
385392
-->
386393
1. 创建一个 Secret 或者使用已有的 Secret。多个 Pod 可以引用同一个 Secret。
@@ -658,8 +665,10 @@ automated Secret updates.
658665
<!--
659666
The kubelet keeps a cache of the current keys and values for the Secrets that are used in
660667
volumes for pods on that node.
661-
You can configure the way that the kubelet detects changes from the cached values. The `configMapAndSecretChangeDetectionStrategy` field in
662-
the [kubelet configuration](/docs/reference/config-api/kubelet-config.v1beta1/) controls which strategy the kubelet uses. The default strategy is `Watch`.
668+
You can configure the way that the kubelet detects changes from the cached values. The
669+
`configMapAndSecretChangeDetectionStrategy` field in the
670+
[kubelet configuration](/docs/reference/config-api/kubelet-config.v1beta1/) controls
671+
which strategy the kubelet uses. The default strategy is `Watch`.
663672
-->
664673
Kubelet 组件会维护一个缓存,在其中保存节点上 Pod 卷中使用的 Secret 的当前主键和取值。
665674
你可以配置 kubelet 如何检测所缓存数值的变化。
@@ -856,7 +865,7 @@ The `imagePullSecrets` field for a Pod is a list of references to Secrets in the
856865
as the Pod.
857866
You can use an `imagePullSecrets` to pass image registry access credentials to
858867
the kubelet. The kubelet uses this information to pull a private image on behalf of your Pod.
859-
See `PodSpec` in the [Pod API reference](/docs/reference/kubernetes-api/workload-resources/pod-v1/#PodSpec)
868+
See the [PodSpec API](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podspec-v1-core)
860869
for more information about the `imagePullSecrets` field.
861870
-->
862871
Pod 的 `imagePullSecrets` 字段是一个对 Pod 所在的名字空间中的 Secret
@@ -884,7 +893,8 @@ See the [PodSpec API](/docs/reference/generated/kubernetes-api/{{< param "versio
884893
<!--
885894
##### Manually specifying an imagePullSecret
886895
887-
You can learn how to specify `imagePullSecrets` from the [container images](/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod)
896+
You can learn how to specify `imagePullSecrets` from the
897+
[container images](/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod)
888898
documentation.
889899
-->
890900
##### 手动设定 imagePullSecret {#manually-specifying-an-imagepullsecret}
@@ -895,12 +905,11 @@ documentation.
895905
<!--
896906
##### Arranging for imagePullSecrets to be automatically attached
897907
898-
You can manually create `imagePullSecrets`, and reference these from
899-
a ServiceAccount. Any Pods created with that ServiceAccount
900-
or created with that ServiceAccount by default, will get their `imagePullSecrets`
901-
field set to that of the service account.
908+
You can manually create `imagePullSecrets`, and reference these from a ServiceAccount. Any Pods
909+
created with that ServiceAccount or created with that ServiceAccount by default, will get their
910+
`imagePullSecrets` field set to that of the service account.
902911
See [Add ImagePullSecrets to a service account](/docs/tasks/configure-pod-container/configure-service-account/#add-imagepullsecrets-to-a-service-account)
903-
for a detailed explanation of that process.
912+
for a detailed explanation of that process.
904913
-->
905914
##### 设置 imagePullSecrets 为自动挂载 {#arranging-for-imagepullsecrets-to-be-automatically-attached}
906915

@@ -913,8 +922,7 @@ See [Add ImagePullSecrets to a service account](/docs/tasks/configure-pod-contai
913922
<!--
914923
### Using Secrets with static Pods {#restriction-static-pod}
915924
916-
You cannot use ConfigMaps or Secrets with
917-
{{< glossary_tooltip text="static Pods" term_id="static-pod" >}}.
925+
You cannot use ConfigMaps or Secrets with {{< glossary_tooltip text="static Pods" term_id="static-pod" >}}.
918926
-->
919927
### 在静态 Pod 中使用 Secret {#restriction-static-pod}
920928

@@ -955,7 +963,8 @@ kubectl apply -f mysecret.yaml
955963
```
956964

957965
<!--
958-
Use `envFrom` to define all of the Secret's data as container environment variables. The key from the Secret becomes the environment variable name in the Pod.
966+
Use `envFrom` to define all of the Secret's data as container environment variables. The key from
967+
the Secret becomes the environment variable name in the Pod.
959968
-->
960969
使用 `envFrom` 来将 Secret 的所有数据定义为容器的环境变量。
961970
来自 Secret 的主键成为 Pod 中的环境变量名称:
@@ -1065,9 +1074,8 @@ The container is then free to use the secret data to establish an SSH connection
10651074
<!--
10661075
### Use case: Pods with prod / test credentials
10671076
1068-
This example illustrates a Pod which consumes a secret containing production
1069-
credentials and another Pod which consumes a secret with test environment
1070-
credentials.
1077+
This example illustrates a Pod which consumes a secret containing production credentials and
1078+
another Pod which consumes a secret with test environment credentials.
10711079
10721080
You can create a `kustomization.yaml` with a `secretGenerator` field or run
10731081
`kubectl create secret`.
@@ -1113,7 +1121,8 @@ secret "test-db-secret" created
11131121

11141122
{{< note >}}
11151123
<!--
1116-
Special characters such as `$`, `\`, `*`, `=`, and `!` will be interpreted by your [shell](https://en.wikipedia.org/wiki/Shell_(computing)) and require escaping.
1124+
Special characters such as `$`, `\`, `*`, `=`, and `!` will be interpreted by your
1125+
[shell](https://en.wikipedia.org/wiki/Shell_(computing)) and require escaping.
11171126
-->
11181127
特殊字符(例如 `$``\``*``=``!`)会被你的
11191128
[Shell](https://zh.wikipedia.org/wiki/%E6%AE%BC%E5%B1%A4) 解释,因此需要转义。
@@ -1730,8 +1739,7 @@ You can create an `Opaque` type for credentials used for basic authentication.
17301739
However, using the defined and public Secret type (`kubernetes.io/basic-auth`) helps other
17311740
people to understand the purpose of your Secret, and sets a convention for what key names
17321741
to expect.
1733-
The Kubernetes API verifies that the required keys are set for a Secret
1734-
of this type.
1742+
The Kubernetes API verifies that the required keys are set for a Secret of this type.
17351743
-->
17361744
提供基本身份认证类型的 Secret 仅仅是出于方便性考虑。
17371745
你也可以使用 `Opaque` 类型来保存用于基本身份认证的凭据。
@@ -1776,8 +1784,7 @@ You could instead create an `Opaque` type Secret for credentials used for SSH au
17761784
However, using the defined and public Secret type (`kubernetes.io/ssh-auth`) helps other
17771785
people to understand the purpose of your Secret, and sets a convention for what key names
17781786
to expect.
1779-
and the API server does verify if the required keys are provided in a Secret
1780-
configuration.
1787+
and the API server does verify if the required keys are provided in a Secret configuration.
17811788
-->
17821789
提供 SSH 身份认证类型的 Secret 仅仅是出于用户方便性考虑。
17831790
你也可以使用 `Opaque` 类型来保存用于 SSH 身份认证的凭据。
@@ -1789,8 +1796,7 @@ API 服务器确实会检查 Secret 配置中是否提供了所需要的主键
17891796
<!--
17901797
SSH private keys do not establish trusted communication between an SSH client and
17911798
host server on their own. A secondary means of establishing trust is needed to
1792-
mitigate "man in the middle" attacks, such as a `known_hosts` file added to a
1793-
ConfigMap.
1799+
mitigate "man in the middle" attacks, such as a `known_hosts` file added to a ConfigMap.
17941800
-->
17951801
SSH 私钥自身无法建立 SSH 客户端与服务器端之间的可信连接。
17961802
需要其它方式来建立这种信任关系,以缓解“中间人(Man In The Middle)”
@@ -2142,6 +2148,7 @@ Secrets used on that node.
21422148
- Learn how to [manage Secrets using kustomize](/docs/tasks/configmap-secret/managing-secret-using-kustomize/)
21432149
- Read the [API reference](/docs/reference/kubernetes-api/config-and-storage-resources/secret-v1/) for `Secret`
21442150
-->
2151+
21452152
- 有关管理和提升 Secret 安全性的指南,请参阅 [Kubernetes Secret 良好实践](/zh-cn/docs/concepts/security/secrets-good-practices)
21462153
- 学习如何[使用 `kubectl` 管理 Secret](/zh-cn/docs/tasks/configmap-secret/managing-secret-using-kubectl/)
21472154
- 学习如何[使用配置文件管理 Secret](/zh-cn/docs/tasks/configmap-secret/managing-secret-using-config-file/)

0 commit comments

Comments
 (0)