@@ -15,39 +15,46 @@ weight: 370
15
15
16
16
<!--
17
17
This page shows how to configure a Key Management Service (KMS) provider and plugin to enable secret data encryption.
18
- Currently there are two KMS API versions. New integrations that only need to support Kubernetes v1.27+
19
- should use KMS v2 as it offers significantly better performance characteristics than v1
20
- (note the `Caution` sections below for specific cases when KMS v2 must not be used.)
18
+ In Kubernetes {{< skew currentVersion >}} there are two versions of KMS at-rest encryption.
19
+ You should use KMS v2 if feasible because KMS v1 is deprecated (since Kubernetes v1.28).
20
+ However, you should also read and observe the **Caution** notices in this page that highlight specific
21
+ cases when you must not use KMS v2. KMS v2 offers significantly better performance characteristics than KMS v1.
21
22
-->
22
23
本页展示了如何配置密钥管理服务(Key Management Service,KMS)驱动和插件以启用 Secret 数据加密。
23
- 目前有两个 KMS API 版本。如果是只需要支持 Kubernetes v1.27+ 的新场景,应使用 KMS v2,
24
- 因为 KMS v2 相比 KMS v1 具有显著更佳的性能特征。
25
- (请注意,下文的“注意”部分说明了不得使用 KMS v2 的特殊场景。)
24
+ 在 Kubernetes {{< skew currentVersion >}} 中,存在两个版本的 KMS 静态加密方式。
25
+ 如果可行的话,建议使用 KMS v2,因为(自 Kubernetes v1.28 起)KMS v1 已经被弃用。
26
+ 然而,在某些特殊情况下没办法使用 KMS v2,你应阅读和关注本页中强调的 ** 注意** 事项。
27
+ KMS v2 提供了比 KMS v1 明显更好的性能特征。
26
28
27
29
## {{% heading "prerequisites" %}}
28
30
29
31
{{< include "task-tutorial-prereqs.md" >}}
30
32
31
33
<!--
32
34
The version of Kubernetes that you need depends on which KMS API version
33
- you have selected.
35
+ you have selected. Kubernetes recommends using KMS v2.
34
36
35
- - If you selected KMS API v1, any supported Kubernetes version will work fine.
36
37
- If you selected KMS API v2, you should use Kubernetes v{{< skew currentVersion >}}
37
38
(if you are running a different version of Kubernetes that also supports the v2 KMS
38
39
API, switch to the documentation for that version of Kubernetes).
40
+ - If you selected KMS API v1 to support clusters prior to version v1.27
41
+ or if you have a legacy KMS plugin that only supports KMS v1,
42
+ any supported Kubernetes version will work. This API is deprecated as of Kubernetes v1.28.
43
+ Kubernetes does not recommend the use of this API.
39
44
-->
40
- 你所需要的 Kubernetes 版本取决于你已选择的 KMS API 版本。
45
+ 你所需要的 Kubernetes 版本取决于你已选择的 KMS API 版本。Kubernetes 推荐使用 KMS v2。
41
46
42
- - 如果你选择了 KMS API v1,所有受支持的 Kubernetes 版本都可以正常工作。
43
47
- 如果你选择了 KMS API v2,则应使用 Kubernetes v{{< skew currentVersion >}}
44
48
(如果你正在运行也支持 KMS API v2 的其他 Kubernetes 版本,需查阅该 Kubernetes 版本的文档)。
49
+ - 如果你选择了 KMS API v1 来支持早于 v1.27 版本的集群,或者你有一个仅支持 KMS v1 的旧版 KMS 插件,
50
+ 那么任何受支持的 Kubernetes 版本都可以良好工作。此 API 自 Kubernetes v1.28 起被弃用。
51
+ Kubernetes 不推荐使用此 API。
45
52
46
53
{{< version-check >}}
47
54
48
55
### KMS v1
49
56
50
- {{< feature-state for_k8s_version="v1.12 " state="beta " >}}
57
+ {{< feature-state for_k8s_version="v1.28 " state="deprecated " >}}
51
58
52
59
<!--
53
60
* Kubernetes version 1.10.0 or later is required
@@ -64,11 +71,19 @@ you have selected.
64
71
<!--
65
72
* For version 1.25 and 1.26, enabling the feature via kube-apiserver feature gate is required.
66
73
Set `--feature-gates=KMSv2=true` to configure a KMS v2 provider.
74
+ For environments where all API servers are running version 1.28 or later, and you do not require the ability
75
+ to downgrade to Kubernetes v1.27, you can enable the `KMSv2KDF` feature gate (a beta feature) for more
76
+ robust data encryption key generation. The Kubernetes project recommends enabling KMS v2 KDF if those
77
+ preconditions are met.
67
78
68
79
* Your cluster must use etcd v3 or later
69
80
-->
70
81
* 对于 Kubernetes 1.25 和 1.26 版本,需要通过 kube-apiserver 特性门控启用此特性。
71
82
设置 ` --feature-gates=KMSv2=true ` 以配置 KMS v2 驱动。
83
+ 对于所有 API 服务器正在运行 1.28 或更高的版本并且你不需要降级到 Kubernetes v1.27 的环境,
84
+ 你可以启用 ` KMSv2KDF ` 特性门控(Beta 特性)以生成更稳健的数据加密密钥。
85
+ 如果这些前提条件均已满足,则 Kubernetes 项目建议启用 KMS v2
86
+ 密钥派生函数(Key Derivation Function, KDF)。
72
87
73
88
* 你的集群必须使用 etcd v3 或更高版本。
74
89
@@ -80,6 +95,15 @@ enabled will result in data loss.
80
95
-->
81
96
KMS v2 API 和实现在 v1.25 的 Alpha 版本和 v1.27 的 Beta 版本之间以不兼容的方式进行了更改。
82
97
如果尝试从启用了 Alpha 特性的旧版本进行升级将导致数据丢失。
98
+
99
+ ---
100
+
101
+ <!--
102
+ Running mixed API server versions with some servers at v1.27, and others at v1.28 _with the
103
+ `KMSv2KDF` feature gate enabled_ is **not supported** - and is likely to result in data loss.
104
+ -->
105
+ 不支持在启用 ` KMSv2KDF ` 特性门控的情况下运行一些服务器为 v1.27 而另一些服务器为 v1.28 的混合 API 服务器版本,
106
+ 这可能导致数据丢失。
83
107
{{< /caution >}}
84
108
85
109
<!-- steps -->
@@ -88,31 +112,58 @@ KMS v2 API 和实现在 v1.25 的 Alpha 版本和 v1.27 的 Beta 版本之间以
88
112
The KMS encryption provider uses an envelope encryption scheme to encrypt data in etcd.
89
113
The data is encrypted using a data encryption key (DEK).
90
114
The DEKs are encrypted with a key encryption key (KEK) that is stored and managed in a remote KMS.
115
+
91
116
With KMS v1, a new DEK is generated for each encryption.
92
- With KMS v2, a new DEK is generated on server startup and when the KMS plugin informs the API server
93
- that a KEK rotation has occurred (see `Understanding key_id and Key Rotation` section below).
117
+ -->
118
+ KMS 加密驱动使用封套加密模型来加密 etcd 中的数据。数据使用数据加密密钥(DEK)加密。
119
+ 这些 DEK 经一个密钥加密密钥(KEK)加密后在一个远端的 KMS 中存储和管理。
120
+
121
+ 对于 KMS v1,每次加密将生成新的 DEK。
122
+
123
+ <!--
124
+ With KMS v2, there are two ways for the API server to generate a DEK.
125
+ Kubernetes defaults to generating a new DEK at API server startup, which is then reused
126
+ for resource encryption. However, if you use KMS v2 _and_ enable the `KMSv2KDF`
127
+ [feature gate](/docs/reference/command-line-tools-reference/feature-gates/), then
128
+ Kubernetes instead generates a new DEK **per encryption**: the API server uses a
129
+ _key derivation function_ to generate single use data encryption keys from a secret seed
130
+ combined with some random data.
131
+ Whichever approach you configure, the DEK or seed is also rotated whenever the KEK is rotated
132
+ (see `Understanding key_id and Key Rotation` section below for more details).
133
+ -->
134
+ 对于 KMS v2,API 服务器生成 DEK 有两种方式。
135
+ Kubernetes 默认在 API 服务器启动时生成一个新的 DEK(数据加密密钥),
136
+ 然后重复使用该密钥进行资源加密。然而,如果你使用 KMS v2 并且启用了 ` KMSv2KDF `
137
+ [ 特性门控] ( /zh-cn/docs/reference/command-line-tools-reference/feature-gates/ ) ,
138
+ 则 Kubernetes 将转为为每次加密生成一个新的 DEK:API 服务器使用** 密钥派生函数** 根据
139
+ 秘密的种子数结合一些随机数据生成一次性的数据加密密钥。
140
+ 无论你配置哪种方法,DEK 或种子也会在 KEK 轮换时进行轮换
141
+ (有关更多详细信息,请参阅下面的“了解 key_id 和密钥轮换”章节)。
142
+
143
+ <!--
94
144
The KMS provider uses gRPC to communicate with a specific KMS plugin over a UNIX domain socket.
95
145
The KMS plugin, which is implemented as a gRPC server and deployed on the same host(s)
96
146
as the Kubernetes control plane, is responsible for all communication with the remote KMS.
97
147
-->
98
- KMS 加密驱动使用封套加密模型来加密 etcd 中的数据。数据使用数据加密密钥(DEK)加密。
99
- 这些 DEK 经一个密钥加密密钥(KEK)加密后在一个远端的 KMS 中存储和管理。
100
- 对于 KMS v1,每次加密将生成新的 DEK。对于 KMS v2,在服务器启动和 KMS 插件通知 API
101
- 服务器已出现 KEK 轮换时生成新的 DEK。(参见以下“了解 key_id 和密钥轮换”章节)。
102
148
KMS 驱动使用 gRPC 通过 UNIX 域套接字与一个特定的 KMS 插件通信。
103
149
这个 KMS 插件作为一个 gRPC 服务器被部署在 Kubernetes 控制平面的相同主机上,负责与远端 KMS 的通信。
104
150
105
151
{{< caution >}}
106
152
<!--
107
- If you are running virtual machine (VM) based nodes that leverage VM state store with this feature, you must not use KMS v2.
153
+ If you are running virtual machine (VM) based nodes that leverage VM state store with this feature,
154
+ using KMS v2 is **insecure** and an information security risk unless you also explicitly enable
155
+ the `KMSv2KDF`
156
+ [feature gate](/docs/reference/command-line-tools-reference/feature-gates/).
108
157
109
158
With KMS v2, the API server uses AES-GCM with a 12 byte nonce (8 byte atomic counter and 4 bytes random data) for encryption.
110
159
The following issues could occur if the VM is saved and restored:
111
160
-->
112
- 如果你正在运行基于虚拟机 (VM) 的节点并利用此特性使用 VM 状态存储,则不得使用 KMS v2。
161
+ 如果你正在运行基于虚机的节点并使用虚机状态存储支持本特性,则使用 KMS v2 是** 不安全的** ,
162
+ 且存在信息安全风险,除非你还显式启用了 ` KMSv2KDF `
163
+ [ 特性门控] ( /zh-cn/docs/reference/command-line-tools-reference/feature-gates/ ) 。
113
164
114
165
使用 KMS v2 时,API 服务器使用带有 12 字节随机数(8 字节原子计数器和 4 字节随机数据)
115
- 的 AES-GCM 进行加密。如果保存并恢复 VM ,则可能会出现以下问题:
166
+ 的 AES-GCM 进行加密。如果保存并恢复虚机 ,则可能会出现以下问题:
116
167
117
168
<!--
118
169
1. The counter value may be lost or corrupted if the VM is saved in an inconsistent state or restored improperly.
@@ -121,15 +172,28 @@ The following issues could occur if the VM is saved and restored:
121
172
2. If the VM is restored to a previous state, the counter value may be set back to its previous value,
122
173
resulting in the same nonce being used again.
123
174
-->
124
- 1 . 如果 VM 在不一致的状态下保存或恢复不当 ,则可能会丢失或损坏计数器值。
175
+ 1 . 如果虚机在不一致的状态下保存或恢复不当 ,则可能会丢失或损坏计数器值。
125
176
这可能导致相同的计数器值被用了两次,从而造成两个不同的消息使用相同的随机数。
126
- 2 . 如果将 VM 还原到先前的状态 ,则计数器值可能会被设置回其先前的值,导致再次使用相同的随机数。
177
+ 2 . 如果将虚机还原到先前的状态 ,则计数器值可能会被设置回其先前的值,导致再次使用相同的随机数。
127
178
128
179
<!--
129
180
Although both of these cases are partially mitigated by the 4 byte random nonce, this can compromise
130
181
the security of the encryption.
131
182
-->
132
183
尽管这两种情况都通过 4 字节随机数进行了部分缓解,但这可能会损害加密的安全性。
184
+
185
+ <!--
186
+ If you have enabled the `KMSv2KDF`
187
+ [feature gate](/docs/reference/command-line-tools-reference/feature-gates/) _and_ are using KMS v2
188
+ (not KMS v1), the API server generates single use data encryption keys from a secret seed.
189
+ This eliminates the need for a counter based nonce while avoiding nonce collision concerns.
190
+ It also removes any specific concerns with using KMS v2 and VM state store.
191
+ -->
192
+ 如果你已启用了 ` KMSv2KDF `
193
+ [ 特性门控] ( /zh-cn/docs/reference/command-line-tools-reference/feature-gates/ )
194
+ 并且正在使用 KMS v2(而不是 KMS v1),API 服务器会根据秘密的种子数生成一次性的数据加密密钥。
195
+ 这就不再需要使用基于计数器的随机数 (nonce),同时避免了随机数冲突问题。
196
+ 这样还消除了使用 KMS v2 和虚机状态存储的特定问题。
133
197
{{< /caution >}}
134
198
135
199
<!--
@@ -194,12 +258,12 @@ See [Understanding the encryption at rest configuration.](/docs/tasks/administer
194
258
195
259
To implement a KMS plugin, you can develop a new plugin gRPC server or enable a KMS plugin
196
260
already provided by your cloud provider.
197
- You then integrate the plugin with the remote KMS and deploy it on the Kubernetes master .
261
+ You then integrate the plugin with the remote KMS and deploy it on the Kubernetes control plane .
198
262
-->
199
263
## 实现 KMS 插件 {#implementing-a-kms-plugin}
200
264
201
265
为实现一个 KMS 插件,你可以开发一个新的插件 gRPC 服务器或启用一个由你的云服务驱动提供的 KMS 插件。
202
- 你可以将这个插件与远程 KMS 集成,并把它部署到 Kubernetes 的主服务器上 。
266
+ 你可以将这个插件与远程 KMS 集成,并把它部署到 Kubernetes 控制平面上 。
203
267
204
268
<!--
205
269
### Enabling the KMS supported by your cloud provider
@@ -433,9 +497,10 @@ Then use the functions and data structures in the stub file to develop the serve
433
497
434
498
{{< caution >}}
435
499
<!--
436
- Because you don't control the number of writes performed with the DEK, we recommend rotating the KEK at least every 90 days.
500
+ Because you don't control the number of writes performed with the DEK,
501
+ the Kubernetes project recommends rotating the KEK at least every 90 days.
437
502
-->
438
- 因为你未控制使用 DEK 执行的写入次数,所以建议至少每 90 天轮换一次 KEK。
503
+ 因为你未控制使用 DEK 执行的写入次数,所以 Kubernetes 项目建议至少每 90 天轮换一次 KEK。
439
504
{{< /caution >}}
440
505
441
506
<!--
@@ -479,11 +544,11 @@ KMS 插件可以用额外的元数据对密文进行编码,这些元数据是
479
544
<!--
480
545
### Deploying the KMS plugin
481
546
482
- Ensure that the KMS plugin runs on the same host(s) as the Kubernetes master (s).
547
+ Ensure that the KMS plugin runs on the same host(s) as the Kubernetes API server (s).
483
548
-->
484
549
### 部署 KMS 插件 {#deploying-the-kms-plugin}
485
550
486
- 确保 KMS 插件与 Kubernetes 主服务器运行在同一主机上 。
551
+ 确保 KMS 插件与 Kubernetes API 服务器运行在同一主机上 。
487
552
488
553
<!--
489
554
## Encrypting your data with the KMS provider
0 commit comments