Skip to content

Commit d5b30ca

Browse files
committed
[zh] Sync decrypt-data.md
1 parent 70b445f commit d5b30ca

File tree

1 file changed

+286
-0
lines changed

1 file changed

+286
-0
lines changed
Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
---
2+
title: 解密已静态加密的机密数据
3+
content_type: task
4+
weight: 215
5+
---
6+
<!--
7+
title: Decrypt Confidential Data that is Already Encrypted at Rest
8+
content_type: task
9+
weight: 215
10+
-->
11+
12+
<!-- overview -->
13+
14+
<!--
15+
All of the APIs in Kubernetes that let you write persistent API resource data support
16+
at-rest encryption. For example, you can enable at-rest encryption for
17+
{{< glossary_tooltip text="Secrets" term_id="secret" >}}.
18+
This at-rest encryption is additional to any system-level encryption for the
19+
etcd cluster or for the filesystem(s) on hosts where you are running the
20+
kube-apiserver.
21+
-->
22+
Kubernetes 中允许允许你写入持久性 API 资源数据的所有 API 都支持静态加密。
23+
例如,你可以为 {{< glossary_tooltip text="Secret" term_id="secret" >}} 启用静态加密。
24+
此静态加密是对 etcd 集群或运行 kube-apiserver 的主机上的文件系统的所有系统级加密的补充。
25+
26+
<!--
27+
This page shows how to switch from encryption of API data at rest, so that API data
28+
are stored unencrypted. You might want to do this to improve performance; usually,
29+
though, if it was a good idea to encrypt some data, it's also a good idea to leave them
30+
encrypted.
31+
-->
32+
本文介绍如何停止静态加密 API 数据,以便 API 数据以未加密的形式存储。
33+
你可能希望这样做以提高性能;但通常情况下,如果加密某些数据是个好主意,那么继续加密这些数据也是一个好主意。
34+
35+
{{< note >}}
36+
<!--
37+
This task covers encryption for resource data stored using the
38+
{{< glossary_tooltip text="Kubernetes API" term_id="kubernetes-api" >}}. For example, you can
39+
encrypt Secret objects, including the key-value data they contain.
40+
-->
41+
此任务涵盖使用 {{< glossary_tooltip text="Kubernetes API" term_id="kubernetes-api" >}}
42+
存储的资源数据的加密。例如,你可以加密 Secret 对象,包括它们所包含的键值数据。
43+
44+
<!--
45+
If you wanted to manage encryption for data in filesystems that are mounted into containers, you instead
46+
need to either:
47+
48+
- use a storage integration that provides encrypted
49+
{{< glossary_tooltip text="volumes" term_id="volume" >}}
50+
- encrypt the data within your own application
51+
-->
52+
如果要加密安装到容器中的文件系统中的数据,则需要:
53+
54+
- 使用提供{{< glossary_tooltip text="存储卷" term_id="volume" >}}加密的存储集成方案
55+
- 在你自己的应用中加密数据
56+
{{< /note >}}
57+
58+
## {{% heading "prerequisites" %}}
59+
60+
* {{< include "task-tutorial-prereqs.md" >}}
61+
62+
<!--
63+
* This task assumes that you are running the Kubernetes API server as a
64+
{{< glossary_tooltip text="static pod" term_id="static-pod" >}} on each control
65+
plane node.
66+
67+
* Your cluster's control plane **must** use etcd v3.x (major version 3, any minor version).
68+
-->
69+
* 此任务假设你将 Kubernetes API 服务器组件以{{< glossary_tooltip text="静态 Pod" term_id="static-pod" >}}
70+
方式运行在每个控制平面节点上。
71+
72+
* 集群的控制平面**必须**使用 etcd v3.x(主版本 3,任何次要版本)。
73+
74+
<!--
75+
* To encrypt a custom resource, your cluster must be running Kubernetes v1.26 or newer.
76+
77+
* You should have some API data that are already encrypted.
78+
-->
79+
* 要加密自定义资源,你的集群必须运行 Kubernetes v1.26 或更高版本。
80+
81+
* 你应该有一些已加密的 API 数据。
82+
83+
{{< version-check >}}
84+
85+
<!-- steps -->
86+
87+
<!--
88+
## Determine whether encryption at rest is already enabled
89+
90+
By default, the API server uses an `identity` provider that stores plain-text representations
91+
of resources.
92+
**The default `identity` provider does not provide any confidentiality protection.**
93+
-->
94+
## 确定静态加密是否已被启用 {#determine-whether-encryption-at-rest-is-already-enabled}
95+
96+
默认情况下,API 服务器使用一个名为 `identity` 的提供程序来存储资源的明文表示。
97+
**默认的 `identity` 提供程序不提供任何机密性保护。**
98+
99+
<!--
100+
The `kube-apiserver` process accepts an argument `--encryption-provider-config`
101+
that specifies a path to a configuration file. The contents of that file, if you specify one,
102+
control how Kubernetes API data is encrypted in etcd.
103+
If it is not specified, you do not have encryption at rest enabled.
104+
105+
The format of that configuration file is YAML, representing a configuration API kind named
106+
[`EncryptionConfiguration`](/docs/reference/config-api/apiserver-encryption.v1/).
107+
You can see an example configuration
108+
in [Encryption at rest configuration](/docs/tasks/administer-cluster/encrypt-data/#understanding-the-encryption-at-rest-configuration).
109+
-->
110+
`kube-apiserver` 进程接受参数 `--encryption-provider-config`,该参数指定了配置文件的路径。
111+
如果你指定了一个路径,那么该文件的内容将控制 Kubernetes API 数据在 etcd 中的加密方式。
112+
如果未指定,则表示你未启用静态加密。
113+
114+
该配置文件的格式是 YAML,表示名为
115+
[`EncryptionConfiguration`](/zh-cn/docs/reference/config-api/apiserver-encryption.v1/) 的配置 API 类别。
116+
你可以在[静态加密配置](/zh-cn/docs/tasks/administer-cluster/encrypt-data/#understanding-the-encryption-at-rest-configuration)中查看示例配置。
117+
118+
<!--
119+
If `--encryption-provider-config` is set, check which resources (such as `secrets`) are
120+
configured for encryption, and what provider is used.
121+
Make sure that the preferred provider for that resource type is **not** `identity`; you
122+
only set `identity` (_no encryption_) as default when you want to disable encryption at
123+
rest.
124+
Verify that the first-listed provider for a resource is something **other** than `identity`,
125+
which means that any new information written to resources of that type will be encrypted as
126+
configured. If you do see `identity` as the first-listed provider for any resource, this
127+
means that those resources are being written out to etcd without encryption.
128+
-->
129+
如果设置了 `--encryption-provider-config`,检查哪些资源(如 `secrets`)已配置为进行加密,
130+
并查看所适用的是哪个提供程序。确保该资源类型首选的提供程序 **不是** `identity`
131+
只有在想要禁用静态加密时,才可将 `identity`**无加密**)设置为默认值。
132+
验证资源首选的提供程序是否不是 `identity`,这意味着写入该类型资源的任何新信息都将按照配置被加密。
133+
如果在任何资源的首选提供程序中看到 `identity`,这意味着这些资源将以非加密的方式写入 etcd 中。
134+
135+
<!--
136+
## Decrypt all data {#decrypting-all-data}
137+
138+
This example shows how to stop encrypting the Secret API at rest. If you are encrypting
139+
other API kinds, adjust the steps to match.
140+
-->
141+
## 解密所有数据 {#decrypting-all-data}
142+
143+
本例展示如何停止对 Secret API 进行静态加密。如果你正在加密其他 API 类别,可以相应调整以下步骤。
144+
145+
<!--
146+
### Locate the encryption configuration file
147+
148+
First, find the API server configuration files. On each control plane node, static Pod manifest
149+
for the kube-apiserver specifies a command line argument, `--encryption-provider-config`.
150+
You are likely to find that this file is mounted into the static Pod using a
151+
[`hostPath`](/docs/concepts/storage/volumes/#hostpath) volume mount. Once you locate the volume
152+
you can find the file on the node filesystem and inspect it.
153+
-->
154+
### 找到加密配置文件 {#locate-encryption-configuration-file}
155+
156+
首先,找到 API 服务器的配置文件。在每个控制平面节点上,kube-apiserver 的静态 Pod
157+
清单指定了一个命令行参数 `--encryption-provider-config`。你很可能会发现此文件通过
158+
[`hostPath`](/zh-cn/docs/concepts/storage/volumes/#hostpath) 卷挂载到静态 Pod 中。
159+
一旦你找到到此卷,就可以在节点文件系统中找到此文件并对其进行检查。
160+
161+
<!--
162+
### Configure the API server to decrypt objects
163+
164+
To disable encryption at rest, place the `identity` provider as the first
165+
entry in your encryption configuration file.
166+
167+
For example, if your existing EncryptionConfiguration file reads:
168+
-->
169+
### 配置 API 服务器以解密对象 {#configure-api-server-to-decrypt-objects}
170+
171+
要禁用静态加密,将 `identity` 提供程序设置为加密配置文件中的第一个条目。
172+
173+
例如,如果你现有的 EncryptionConfiguration 文件内容如下:
174+
175+
<!--
176+
# Do not use this (invalid) example key for encryption
177+
-->
178+
```yaml
179+
---
180+
apiVersion: apiserver.config.k8s.io/v1
181+
kind: EncryptionConfiguration
182+
resources:
183+
- resources:
184+
- secrets
185+
providers:
186+
- aescbc:
187+
keys:
188+
# 你加密时不要使用这个(无效)的示例密钥
189+
- name: example
190+
secret: 2KfZgdiq2K0g2YrYpyDYs9mF2LPZhQ==
191+
```
192+
193+
<!--
194+
then change it to:
195+
-->
196+
然后将其更改为:
197+
198+
<!--
199+
# add this line
200+
-->
201+
```yaml
202+
---
203+
apiVersion: apiserver.config.k8s.io/v1
204+
kind: EncryptionConfiguration
205+
resources:
206+
- resources:
207+
- secrets
208+
providers:
209+
- identity: {} # 增加这一行
210+
- aescbc:
211+
keys:
212+
- name: example
213+
secret: 2KfZgdiq2K0g2YrYpyDYs9mF2LPZhQ==
214+
```
215+
216+
<!--
217+
and restart the kube-apiserver Pod on this node.
218+
219+
### Reconfigure other control plane hosts {#api-server-config-update-more-1}
220+
221+
If you have multiple API servers in your cluster, you should deploy the changes in turn to each API server.
222+
223+
Make sure that you use the same encryption configuration on each control plane host.
224+
-->
225+
并重启此节点上的 kube-apiserver Pod。
226+
227+
### 重新配置其他控制平面主机 {#api-server-config-update-more-1}
228+
229+
如果你的集群中有多个 API 服务器,应轮流对每个 API 服务器部署这些更改。
230+
231+
确保在每个控制平面主机上使用相同的加密配置。
232+
233+
<!--
234+
### Force decryption
235+
236+
Then run the following command to force decryption of all Secrets:
237+
-->
238+
### 强制解密 {#force-decryption}
239+
240+
然后运行以下命令强制解密所有 Secret:
241+
242+
<!--
243+
# If you are decrypting a different kind of object, change "secrets" to match.
244+
-->
245+
```shell
246+
# 如果你正在解密不同类别的对象,请相应更改 "secrets"
247+
kubectl get secrets --all-namespaces -o json | kubectl replace -f -
248+
```
249+
250+
<!--
251+
Once you have replaced **all** existing encrypted resources with backing data that
252+
don't use encryption, you can remove the encryption settings from the
253+
`kube-apiserver`.
254+
255+
The command line options to remove are:
256+
-->
257+
一旦你用未加密的后台数据替换了**所有**现有的已加密资源,即可从 `kube-apiserver` 中删除这些加密设置。
258+
259+
要移除的命令行选项为:
260+
261+
- `--encryption-provider-config`
262+
- `--encryption-provider-config-automatic-reload`
263+
264+
<!--
265+
Restart the kube-apiserver Pod again to apply the new configuration.
266+
267+
### Reconfigure other control plane hosts {#api-server-config-update-more-2}
268+
269+
If you have multiple API servers in your cluster, you should again deploy the changes in turn to each API server.
270+
271+
Make sure that you use the same encryption configuration on each control plane host.
272+
-->
273+
再次重启 kube-apiserver Pod 以应用新的配置。
274+
275+
### 重新配置其他控制平面主机 {#api-server-config-update-more-2}
276+
277+
如果你的集群中有多个 API 服务器,应再次轮流对每个 API 服务器部署这些更改。
278+
279+
确保在每个控制平面主机上使用相同的加密配置。
280+
281+
## {{% heading "whatsnext" %}}
282+
283+
<!--
284+
* Learn more about the [EncryptionConfiguration configuration API (v1)](/docs/reference/config-api/apiserver-encryption.v1/).
285+
-->
286+
* 更多细节参阅 [EncryptionConfiguration configuration API (v1)](/zh-cn/docs/reference/config-api/apiserver-encryption.v1/)

0 commit comments

Comments
 (0)