Skip to content

Commit 9f38827

Browse files
authored
Merge pull request #35609 from yanrongshi/zh-cn]-update-kms-provider.md
[zh-cn]Sync kms-provider.md
2 parents ac2e878 + 1fdf1d5 commit 9f38827

File tree

1 file changed

+94
-60
lines changed

1 file changed

+94
-60
lines changed

content/zh-cn/docs/tasks/administer-cluster/kms-provider.md

Lines changed: 94 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ title: Using a KMS provider for data encryption
99
content_type: task
1010
-->
1111
<!-- overview -->
12-
<!-- This page shows how to configure a Key Management Service (KMS) provider and plugin to enable secret data encryption. -->
12+
<!--
13+
This page shows how to configure a Key Management Service (KMS) provider and plugin to enable secret data encryption.
14+
-->
1315

1416
本页展示了如何配置秘钥管理服务—— Key Management Service (KMS) 驱动和插件以启用
1517
Secret 数据加密。
@@ -18,8 +20,10 @@ Secret 数据加密。
1820

1921
* {{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
2022

21-
<!-- * Kubernetes version 1.10.0 or later is required -->
22-
<!-- * etcd v3 or later is required -->
23+
<!--
24+
* Kubernetes version 1.10.0 or later is required
25+
* etcd v3 or later is required
26+
-->
2327
* 需要 Kubernetes 1.10.0 或更新版本
2428
* 需要 etcd v3 或更新版本
2529

@@ -28,47 +32,59 @@ Secret 数据加密。
2832
<!-- steps -->
2933

3034
<!--
31-
The KMS encryption provider uses an envelope encryption scheme to encrypt data in etcd. The data is encrypted using a data encryption key (DEK); a new DEK is generated for each encryption. The DEKs are encrypted with a key encryption key (KEK) that is stored and managed in a remote KMS. The KMS provider uses gRPC to communicate with a specific KMS
32-
plugin. The KMS plugin, which is implemented as a gRPC server and deployed on the same host(s) as the Kubernetes master(s), is responsible for all communication with the remote KMS.
35+
The KMS encryption provider uses an envelope encryption scheme to encrypt data in etcd.
36+
The data is encrypted using a data encryption key (DEK); a new DEK is generated for each encryption.
37+
The DEKs are encrypted with a key encryption key (KEK) that is stored and managed in a remote KMS.
38+
The KMS provider uses gRPC to communicate with a specific KMS plugin.
39+
The KMS plugin, which is implemented as a gRPC server and deployed on the same host(s)
40+
as the Kubernetes control plane, is responsible for all communication with the remote KMS.
3341
-->
3442
KMS 加密驱动使用封套加密模型来加密 etcd 中的数据。
3543
数据使用数据加密秘钥(DEK)加密;每次加密都生成一个新的 DEK。
3644
这些 DEK 经一个秘钥加密秘钥(KEK)加密后在一个远端的 KMS 中存储和管理。
3745
KMS 驱动使用 gRPC 与一个特定的 KMS 插件通信。这个 KMS 插件作为一个 gRPC
38-
服务器被部署在 Kubernetes 主服务器的同一个主机上,负责与远端 KMS 的通信。
46+
服务器被部署在 Kubernetes 控制平面的相同主机上,负责与远端 KMS 的通信。
3947

4048
<!--
4149
## Configuring the KMS provider
4250
43-
To configure a KMS provider on the API server, include a provider of type ```kms``` in the providers array in the encryption configuration file and set the following properties:
51+
To configure a KMS provider on the API server, include a provider of type `kms` in the
52+
`providers` array in the encryption configuration file and set the following properties:
4453
-->
45-
## 配置 KMS 驱动
54+
## 配置 KMS 驱动 {#configuring-the-kms-provider}
4655

47-
为了在 API 服务器上配置 KMS 驱动,在加密配置文件中的驱动数组中加入一个类型为 `kms`
56+
为了在 API 服务器上配置 KMS 驱动,在加密配置文件中的 `providers` 数组中加入一个类型为 `kms`
4857
的驱动,并设置下列属性:
4958

5059
<!--
5160
* `name`: Display name of the KMS plugin.
5261
* `endpoint`: Listen address of the gRPC server (KMS plugin). The endpoint is a UNIX domain socket.
53-
* `cachesize`: Number of data encryption keys (DEKs) to be cached in the clear. When cached, DEKs can be used without another call to the KMS; whereas DEKs that are not cached require a call to the KMS to unwrap.
54-
* `timeout`: How long should kube-apiserver wait for kms-plugin to respond before returning an error (default is 3 seconds).
62+
* `cachesize`: Number of data encryption keys (DEKs) to be cached in the clear.
63+
When cached, DEKs can be used without another call to the KMS;
64+
whereas DEKs that are not cached require a call to the KMS to unwrap.
65+
* `timeout`: How long should `kube-apiserver` wait for kms-plugin to respond before
66+
returning an error (default is 3 seconds).
5567
-->
5668

5769
* `name`: KMS 插件的显示名称。
5870
* `endpoint`: gRPC 服务器(KMS 插件)的监听地址。该端点是一个 UNIX 域套接字。
5971
* `cachesize`: 以明文缓存的数据加密秘钥(DEKs)的数量。一旦被缓存,
6072
就可以直接使用 DEKs 而无需另外调用 KMS;而未被缓存的 DEKs 需要调用一次 KMS 才能解包。
61-
* `timeout`: 在返回一个错误之前,kube-apiserver 等待 kms-plugin 响应的时间(默认是 3 秒)。
73+
* `timeout`: 在返回一个错误之前,`kube-apiserver` 等待 kms-plugin 响应的时间(默认是 3 秒)。
6274

63-
<!-- See [Understanding the encryption at rest configuration.](/docs/tasks/administer-cluster/encrypt-data) -->
64-
参见[理解静态数据加密配置](/zh-cn/docs/tasks/administer-cluster/encrypt-data)
75+
<!--
76+
See [Understanding the encryption at rest configuration.](/docs/tasks/administer-cluster/encrypt-data)
77+
-->
78+
参见[理解静态配置加密](/zh-cn/docs/tasks/administer-cluster/encrypt-data)
6579

6680
<!--
6781
## Implementing a KMS plugin
6882
69-
To implement a KMS plugin, you can develop a new plugin gRPC server or enable a KMS plugin already provided by your cloud provider. You then integrate the plugin with the remote KMS and deploy it on the Kubernetes master.
83+
To implement a KMS plugin, you can develop a new plugin gRPC server or enable a KMS plugin
84+
already provided by your cloud provider.
85+
You then integrate the plugin with the remote KMS and deploy it on the Kubernetes master.
7086
-->
71-
## 实现 KMS 插件
87+
## 实现 KMS 插件 {#implementing-a-kms-plugin}
7288

7389
为实现一个 KMS 插件,你可以开发一个新的插件 gRPC 服务器或启用一个由你的云服务驱动提供的 KMS 插件。
7490
你可以将这个插件与远程 KMS 集成,并把它部署到 Kubernetes 的主服务器上。
@@ -77,46 +93,51 @@ To implement a KMS plugin, you can develop a new plugin gRPC server or enable a
7793
### Enabling the KMS supported by your cloud provider
7894
Refer to your cloud provider for instructions on enabling the cloud provider-specific KMS plugin.
7995
-->
80-
### 启用由云服务驱动支持的 KMS
96+
### 启用由云服务驱动支持的 KMS {#enabling-the-kms-supported-by-your-cloud-provider}
8197

8298
有关启用云服务驱动特定的 KMS 插件的说明,请咨询你的云服务驱动商。
8399

84100
<!--
85101
### Developing a KMS plugin gRPC server
86102
87-
You can develop a KMS plugin gRPC server using a stub file available for Go. For other languages, you use a proto file to create a stub file that you can use to develop the gRPC server code.
103+
You can develop a KMS plugin gRPC server using a stub file available for Go. For other languages,
104+
you use a proto file to create a stub file that you can use to develop the gRPC server code.
88105
-->
89-
### 开发 KMS 插件 gRPC 服务器
106+
### 开发 KMS 插件 gRPC 服务器 {#developing-a-kms-plugin-grpc-server}
90107

91108
你可以使用 Go 语言的存根文件开发 KMS 插件 gRPC 服务器。
92109
对于其他语言,你可以用 proto 文件创建可以用于开发 gRPC 服务器代码的存根文件。
93110

94111
<!--
95112
* Using Go: Use the functions and data structures in the stub file:
96-
[service.pb.go](https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/v1beta1/service.pb.go) to develop the gRPC server code
113+
[service.pb.go](https://github.com/kubernetes/kubernetes/blob/release-1.24/staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/v1beta1/service.pb.go)
114+
to develop the gRPC server code
97115
-->
98-
* 使用 Go:使用存根文件 [service.pb.go](https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/v1beta1/service.pb.go)
116+
* 使用 Go:使用存根文件 [service.pb.go](https://github.com/kubernetes/kubernetes/blob/release-1.24/staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/v1beta1/service.pb.go)
99117
中的函数和数据结构开发 gRPC 服务器代码。
100118

101119
<!--
102-
* Using languages other than Go: Use the protoc compiler with the proto file: [service.proto](https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/v1beta1/service.proto) to generate a stub file for the specific language
120+
* Using languages other than Go: Use the protoc compiler with the proto file:
121+
[service.proto](https://github.com/kubernetes/kubernetes/blob/release-1.24/staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/v1beta1/service.proto)
122+
to generate a stub file for the specific language
103123
-->
104124
* 使用 Go 以外的其他语言:用 protoc 编译器编译 proto 文件:
105-
[service.proto](https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/v1beta1/service.proto)
125+
[service.proto](https://github.com/kubernetes/kubernetes/blob/release-1.24/staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/v1beta1/service.proto)
106126
为指定语言生成存根文件。
107127

108128
<!--
109129
Then use the functions and data structures in the stub file to develop the server code.
110130
-->
111131
然后使用存根文件中的函数和数据结构开发服务器代码。
112132

113-
<!-- **Notes:** -->
133+
<!--
134+
**Notes:**
135+
-->
114136
**注意:**
115137

116138
<!--
117139
* kms plugin version: `v1beta1`
118-
119-
In response to procedure call Version, a compatible KMS plugin should return v1beta1 as VersionResponse.version.
140+
In response to procedure call Version, a compatible KMS plugin should return `v1beta1` as `VersionResponse.version`.
120141
121142
* message version: `v1beta1`
122143
@@ -128,7 +149,7 @@ Then use the functions and data structures in the stub file to develop the serve
128149
-->
129150
* kms 插件版本:`v1beta1`
130151

131-
作为对过程调用 Version 的响应,兼容的 KMS 插件应把 v1beta1 作为 VersionResponse.version 返回
152+
作为对过程调用 Version 的响应,兼容的 KMS 插件应把 `v1beta1` 作为 `VersionResponse.version` 版本返回。
132153

133154
* 消息版本:`v1beta1`
134155

@@ -143,9 +164,10 @@ Then use the functions and data structures in the stub file to develop the serve
143164
144165
The KMS plugin can communicate with the remote KMS using any protocol supported by the KMS.
145166
All configuration data, including authentication credentials the KMS plugin uses to communicate with the remote KMS,
146-
are stored and managed by the KMS plugin independently. The KMS plugin can encode the ciphertext with additional metadata that may be required before sending it to the KMS for decryption.
167+
are stored and managed by the KMS plugin independently.
168+
The KMS plugin can encode the ciphertext with additional metadata that may be required before sending it to the KMS for decryption.
147169
-->
148-
### 将 KMS 插件与远程 KMS 整合
170+
### 将 KMS 插件与远程 KMS 整合 {#integrating-a-kms-plugin-with-the-remote-kms}
149171

150172
KMS 插件可以用任何受 KMS 支持的协议与远程 KMS 通信。
151173
所有的配置数据,包括 KMS 插件用于与远程 KMS 通信的认证凭据,都由 KMS 插件独立地存储和管理。
@@ -156,7 +178,7 @@ KMS 插件可以用额外的元数据对密文进行编码,这些元数据是
156178
157179
Ensure that the KMS plugin runs on the same host(s) as the Kubernetes master(s).
158180
-->
159-
### 部署 KMS 插件
181+
### 部署 KMS 插件 {#deploying-the-kms-plugin}
160182

161183
确保 KMS 插件与 Kubernetes 主服务器运行在同一主机上。
162184

@@ -165,7 +187,7 @@ Ensure that the KMS plugin runs on the same host(s) as the Kubernetes master(s).
165187
166188
To encrypt the data:
167189
-->
168-
## 使用 KMS 驱动加密数据
190+
## 使用 KMS 驱动加密数据 {#encrypting-your-data-with-the-kms-provider}
169191

170192
为了加密数据:
171193

@@ -175,8 +197,8 @@ To encrypt the data:
175197
1. 使用 `kms` 驱动的相应的属性创建一个新的加密配置文件:
176198

177199
```yaml
178-
kind: EncryptionConfiguration
179200
apiVersion: apiserver.config.k8s.io/v1
201+
kind: EncryptionConfiguration
180202
resources:
181203
- resources:
182204
- secrets
@@ -190,54 +212,65 @@ To encrypt the data:
190212
```
191213
192214
<!--
193-
2. Set the `--encryption-provider-config` flag on the kube-apiserver to point to the location of the configuration file.
194-
3. Restart your API server.
215+
1. Set the `--encryption-provider-config` flag on the kube-apiserver to point to
216+
the location of the configuration file.
217+
1. Restart your API server.
195218
-->
196219
2. 设置 kube-apiserver 的 `--encryption-provider-config` 参数指向配置文件的位置。
197220
3. 重启 API 服务器。
198221

222+
<!--
223+
For details about the `EncryptionConfiguration` format, please check the
224+
[API server encryption API reference](/docs/reference/config-api/apiserver-encryption.v1/).
225+
-->
226+
有关 `EncryptionConfiguration` 格式的更多详细信息,请参阅
227+
[kube-apiserver 加密 API 参考 (v1)](/zh-cn/docs/reference/config-api/apiserver-encryption.v1/).
228+
199229
<!--
200230
## Verifying that the data is encrypted
201231

202-
Data is encrypted when written to etcd. After restarting your kube-apiserver, any newly created or updated secret should be encrypted when stored. To verify, you can use the etcdctl command line program to retrieve the contents of your secret.
232+
Data is encrypted when written to etcd. After restarting your `kube-apiserver`,
233+
any newly created or updated secret should be encrypted when stored. To verify,
234+
you can use the `etcdctl` command line program to retrieve the contents of your secret.
203235
-->
204-
## 验证数据已经加密
236+
## 验证数据已经加密 {#verifying-that-the-data-is-encrypted}
205237

206-
写入 etcd 时数据被加密。重启 kube-apiserver 后,任何新建或更新的 Secret 在存储时应该已被加密。
207-
要验证这点,你可以用 etcdctl 命令行程序获取 Secret 内容。
238+
写入 etcd 时数据被加密。重启 `kube-apiserver` 后,任何新建或更新的 Secret 在存储时应该已被加密。
239+
要验证这点,你可以用 `etcdctl` 命令行程序获取 Secret 内容。
208240

209241
<!--
210-
1. Create a new secret called secret1 in the default namespace:
242+
1. Create a new secret called `secret1` in the `default` namespace:
211243
-->
212-
1. 在默认的命名空间里创建一个名为 secret1 的 Secret:
244+
1. 在默认的命名空间里创建一个名为 `secret1` 的 Secret:
213245

214246
```
215247
kubectl create secret generic secret1 -n default --from-literal=mykey=mydata
216248
```
217249
218250
<!--
219-
2. Using the etcdctl command line, read that secret out of etcd:
251+
1. Using the `etcdctl` command line, read that secret out of etcd:
220252
-->
221-
2. 用 etcdctl 命令行,从 etcd 读取出 Secret:
253+
2. 用 `etcdctl` 命令行,从 etcd 读取出 Secret:
222254
223255
```
224256
ETCDCTL_API=3 etcdctl get /kubernetes.io/secrets/default/secret1 [...] | hexdump -C
225257
```
226258
227259
<!--
228-
where `[...]` must be the additional arguments for connecting to the etcd server.
260+
where `[...]` contains the additional arguments for connecting to the etcd server.
229261
-->
230-
其中 `[...]` 是用于连接 etcd 服务器的额外参数。
262+
其中 `[...]` 包含连接 etcd 服务器的额外参数。
231263
232264
<!--
233-
3. Verify the stored secret is prefixed with `k8s:enc:kms:v1:`, which indicates that the `kms` provider has encrypted the resulting data.
265+
1. Verify the stored secret is prefixed with `k8s:enc:kms:v1:`, which indicates that
266+
the `kms` provider has encrypted the resulting data.
234267
-->
235268
3. 验证保存的 Secret 是否是以 `k8s:enc:kms:v1:` 开头的,这表明 `kms` 驱动已经对结果数据加密。
236269
237270
<!--
238-
4. Verify that the secret is correctly decrypted when retrieved via the API:
271+
1. Verify that the secret is correctly decrypted when retrieved via the API:
239272
-->
240-
4. 验证 Secret 在被 API 获取时已被正确解密
273+
4. 验证通过 API 获取的 Secret 已被正确解密
241274
242275
```
243276
kubectl describe secret secret1 -n default
@@ -250,12 +283,13 @@ Data is encrypted when written to etcd. After restarting your kube-apiserver, an
250283
251284
Because secrets are encrypted on write, performing an update on a secret encrypts that content.
252285
-->
253-
## 确保所有 Secret 都已被加密
286+
## 确保所有 Secret 都已被加密 {#ensuring-all-secrets-are-encrypted}
254287
255288
因为 Secret 是在写入时被加密的,所以在更新 Secret 时也会加密该内容。
256289
257290
<!--
258-
The following command reads all secrets and then updates them to apply server side encryption. If an error occurs due to a conflicting write, retry the command.
291+
The following command reads all secrets and then updates them to apply server side encryption.
292+
If an error occurs due to a conflicting write, retry the command.
259293
For larger clusters, you may wish to subdivide the secrets by namespace or script an update.
260294
-->
261295
下列命令读取所有 Secret 并更新它们以便应用服务器端加密。如果因为写入冲突导致错误发生,
@@ -270,7 +304,7 @@ kubectl get secrets --all-namespaces -o json | kubectl replace -f -
270304
271305
To switch from a local encryption provider to the `kms` provider and re-encrypt all of the secrets:
272306
-->
273-
## 从本地加密驱动切换到 KMS 驱动
307+
## 从本地加密驱动切换到 KMS 驱动 {#switching-from-a-local-encryption-provider-to-the-kms-provider}
274308
275309
为了从本地加密驱动切换到 `kms` 驱动并重新加密所有 Secret 内容:
276310
@@ -280,8 +314,8 @@ To switch from a local encryption provider to the `kms` provider and re-encrypt
280314
1. 在配置文件中加入 `kms` 驱动作为第一个条目,如下列样例所示
281315
282316
```yaml
283-
kind: EncryptionConfiguration
284317
apiVersion: apiserver.config.k8s.io/v1
318+
kind: EncryptionConfiguration
285319
resources:
286320
- resources:
287321
- secrets
@@ -297,21 +331,21 @@ To switch from a local encryption provider to the `kms` provider and re-encrypt
297331
```
298332

299333
<!--
300-
2. Restart all kube-apiserver processes.
301-
3. Run the following command to force all secrets to be re-encrypted using the `kms` provider.
334+
1. Restart all `kube-apiserver` processes.
335+
1. Run the following command to force all secrets to be re-encrypted using the `kms` provider.
302336
-->
303-
2. 重启所有 kube-apiserver 进程。
337+
2. 重启所有 `kube-apiserver` 进程。
304338
3. 运行下列命令使用 `kms` 驱动强制重新加密所有 Secret。
305339

306340
```
307-
kubectl get secrets --all-namespaces -o json| kubectl replace -f -
341+
kubectl get secrets --all-namespaces -o json | kubectl replace -f -
308342
```
309343

310344
<!--
311345
## Disabling encryption at rest
312346
To disable encryption at rest:
313347
-->
314-
## 禁用静态数据加密
348+
## 禁用静态数据加密 {#disabling-encryption-at-rest}
315349

316350
要禁用静态数据加密:
317351

@@ -321,8 +355,8 @@ To disable encryption at rest:
321355
1.`identity` 驱动作为配置文件中的第一个条目:
322356

323357
```yaml
324-
kind: EncryptionConfiguration
325358
apiVersion: apiserver.config.k8s.io/v1
359+
kind: EncryptionConfiguration
326360
resources:
327361
- resources:
328362
- secrets
@@ -335,10 +369,10 @@ To disable encryption at rest:
335369
```
336370
337371
<!--
338-
2. Restart all kube-apiserver processes.
339-
3. Run the following command to force all secrets to be decrypted.
372+
1. Restart all `kube-apiserver` processes.
373+
1. Run the following command to force all secrets to be decrypted.
340374
-->
341-
2. 重启所有 kube-apiserver 进程。
375+
2. 重启所有 `kube-apiserver` 进程。
342376
3. 运行下列命令强制重新加密所有 Secret。
343377

344378
```

0 commit comments

Comments
 (0)