You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -99,30 +99,116 @@ See [Information security for Secrets](#information-security-for-secrets) for mo
99
99
<!--
100
100
## Uses for Secrets
101
101
102
-
There are three main ways for a Pod to use a Secret:
103
-
- As [files](#using-secrets-as-files-from-a-pod) in a
104
-
{{< glossary_tooltip text="volume" term_id="volume" >}} mounted on one or more of
105
-
its containers.
106
-
- As [container environment variable](#using-secrets-as-environment-variables).
107
-
- By the [kubelet when pulling images](#using-imagepullsecrets) for the Pod.
102
+
You can use Secrets for purposes such as the following:
103
+
- [Set environment variables for a container](/docs/tasks/inject-data-application/distribute-credentials-secure/#define-container-environment-variables-using-secret-data).
104
+
- [Provide credentials such as SSH keys or passwords to Pods](/docs/tasks/inject-data-application/distribute-credentials-secure/#provide-prod-test-creds).
105
+
- [Allow the kubelet to pull container images from private registries](/docs/tasks/configure-pod-container/pull-image-private-registry/).
108
106
109
107
The Kubernetes control plane also uses Secrets; for example,
110
108
[bootstrap token Secrets](#bootstrap-token-secrets) are a mechanism to
Files beginning with dot characters are hidden from the output of `ls -l`;
143
+
you must use `ls -la` to see them when listing directory contents.
144
+
-->
145
+
以句点开头的文件会在 `ls -l` 的输出中被隐藏起来;
146
+
列举目录内容时你必须使用 `ls -la` 才能看到它们。
147
+
{{< /note >}}
148
+
149
+
```yaml
150
+
apiVersion: v1
151
+
kind: Secret
152
+
metadata:
153
+
name: dotfile-secret
154
+
data:
155
+
.secret-file: dmFsdWUtMg0KDQo=
156
+
---
157
+
apiVersion: v1
158
+
kind: Pod
159
+
metadata:
160
+
name: secret-dotfiles-pod
161
+
spec:
162
+
volumes:
163
+
- name: secret-volume
164
+
secret:
165
+
secretName: dotfile-secret
166
+
containers:
167
+
- name: dotfile-test-container
168
+
image: registry.k8s.io/busybox
169
+
command:
170
+
- ls
171
+
- "-l"
172
+
- "/etc/secret-volume"
173
+
volumeMounts:
174
+
- name: secret-volume
175
+
readOnly: true
176
+
mountPath: "/etc/secret-volume"
177
+
```
178
+
179
+
<!--
180
+
### Use case: Secret visible to one container in a Pod
181
+
182
+
Consider a program that needs to handle HTTP requests, do some complex business
183
+
logic, and then sign some messages with an HMAC. Because it has complex
184
+
application logic, there might be an unnoticed remote file reading exploit in
185
+
the server, which could expose the private key to an attacker.
186
+
-->
187
+
### 使用场景:仅对 Pod 中一个容器可见的 Secret {#use-case-secret-visible-to-one-container-in-a-pod}
188
+
189
+
考虑一个需要处理 HTTP 请求,执行某些复杂的业务逻辑,之后使用 HMAC
190
+
来对某些消息进行签名的程序。因为这一程序的应用逻辑很复杂,
191
+
其中可能包含未被注意到的远程服务器文件读取漏洞,
192
+
这种漏洞可能会把私钥暴露给攻击者。
193
+
194
+
<!--
195
+
This could be divided into two processes in two containers: a frontend container
196
+
which handles user interaction and business logic, but which cannot see the
197
+
private key; and a signer container that can see the private key, and responds
198
+
to simple signing requests from the frontend (for example, over localhost networking).
199
+
-->
200
+
这一程序可以分隔成两个容器中的两个进程:前端容器要处理用户交互和业务逻辑,
201
+
但无法看到私钥;签名容器可以看到私钥,并对来自前端的简单签名请求作出响应
202
+
(例如,通过本地主机网络)。
203
+
204
+
<!--
205
+
With this partitioned approach, an attacker now has to trick the application
206
+
server into doing something rather arbitrary, which may be harder than getting
207
+
it to read a file.
208
+
-->
209
+
采用这种划分的方法,攻击者现在必须欺骗应用服务器来做一些其他操作,
210
+
而这些操作可能要比读取一个文件要复杂很多。
211
+
126
212
<!--
127
213
### Alternatives to Secrets
128
214
@@ -423,12 +509,13 @@ for information on referencing service account credentials from within Pods.
423
509
<!--
424
510
### Docker config Secrets
425
511
426
-
You can use one of the following `type` values to create a Secret to
427
-
store the credentials for accessing a container image registry:
512
+
If you are creating a Secret to store credentials for accessing a container image registry,
513
+
you must use one of the following `type` values for that Secret:
428
514
-->
429
515
### Docker 配置 Secret {#docker-config-secrets}
430
516
431
-
你可以使用下面两种 `type` 值之一来创建 Secret,用以存放用于访问容器镜像仓库的凭据:
517
+
如果你要创建 Secret 用来存放用于访问容器镜像仓库的凭据,则必须选用以下 `type`
518
+
值之一来创建 Secret:
432
519
433
520
- `kubernetes.io/dockercfg`
434
521
- `kubernetes.io/dockerconfigjson`
@@ -537,14 +624,19 @@ Docker configuration file):
537
624
}
538
625
```
539
626
540
-
{{< note >}}
627
+
{{< caution >}}
541
628
<!--
542
629
The `auth` value there is base64 encoded; it is obscured but not secret.
543
630
Anyone who can read that Secret can learn the registry access bearer token.
631
+
632
+
It is suggested to use [credential providers](/docs/tasks/administer-cluster/kubelet-credential-provider/) to dynamically and securely provide pull secrets on-demand.
@@ -669,6 +761,8 @@ When using this type of Secret, the `tls.key` and the `tls.crt` key must be prov
669
761
in the `data` (or `stringData`) field of the Secret configuration, although the API
670
762
server doesn't actually validate the values for each key.
671
763
764
+
As an alternative to using `stringData`, you can use the `data` field to provide the base64 encoded certificate and private key. Refer to [Constraints on Secret names and data](#restriction-names-data) for more on this.
765
+
672
766
The following YAML contains an example config for a TLS Secret:
0 commit comments