@@ -39,6 +39,7 @@ encrypt Secret objects, including the key-value data they contain.
39
39
此任务涵盖使用 {{< glossary_tooltip text="Kubernetes API" term_id="kubernetes-api" >}}
40
40
存储的资源数据的加密。
41
41
例如,你可以加密 Secret 对象,包括它们包含的键值数据。
42
+
42
43
<!--
43
44
If you want to encrypt data in filesystems that are mounted into containers, you instead need
44
45
to either:
@@ -274,7 +275,7 @@ read that resource will fail until it is deleted or a valid decryption key is pr
274
275
任何尝试读取资源的调用将会失败,直到它被删除或提供有效的解密密钥。
275
276
{{< /caution >}}
276
277
277
- # ## Providers
278
+ # ## Provider
278
279
279
280
<!--
280
281
The following table describes each available provider :
@@ -283,7 +284,9 @@ The following table describes each available provider:
283
284
284
285
<table class="complex-layout">
285
286
<caption style="display : none;">
286
- <!-- Providers for Kubernetes encryption at rest -->
287
+ <!--
288
+ Providers for Kubernetes encryption at rest
289
+ -->
287
290
Kubernetes 静态数据加密的 Provider
288
291
</caption>
289
292
<thead>
@@ -306,8 +309,10 @@ Kubernetes 静态数据加密的 Provider
306
309
</tr>
307
310
<tr>
308
311
<td colspan="4">
309
- <!-- Resources written as-is without encryption. When set as the first provider, the resource will be decrypted as new values are written. Existing encrypted resources are <strong>not</strong> automatically overwritten with the plaintext data.
310
- The <tt>identity</tt> provider is the default if you do not specify otherwise. -->
312
+ <!--
313
+ Resources written as-is without encryption. When set as the first provider, the resource will be decrypted as new values are written. Existing encrypted resources are <strong>not</strong> automatically overwritten with the plaintext data.
314
+ The <tt>identity</tt> provider is the default if you do not specify otherwise.
315
+ -->
311
316
不加密写入的资源。当设置为第一个 provider 时,已加密的资源将在新值写入时被解密。
312
317
</td>
313
318
</tr>
@@ -316,7 +321,9 @@ Kubernetes 静态数据加密的 Provider
316
321
<tr>
317
322
<th rowspan="2" scope="row"><tt>aescbc</tt></th>
318
323
<td>
319
- <!-- AES-CBC with <a href="https://datatracker.ietf.org/doc/html/rfc2315">PKCS#7</a> padding -->
324
+ <!--
325
+ AES-CBC with <a href="https://datatracker.ietf.org/doc/html/rfc2315">PKCS#7</a> padding
326
+ -->
320
327
带有 <a href="https://datatracker.ietf.org/doc/html/rfc2315">PKCS#7</a> 填充的 AES-CBC
321
328
</td>
322
329
<td><!-- Weak -->弱</td>
@@ -325,33 +332,43 @@ Kubernetes 静态数据加密的 Provider
325
332
</tr>
326
333
<tr>
327
334
<td colspan="4">
328
- <!-- Not recommended due to CBC's vulnerability to padding oracle attacks. Key material accessible from control plane host. -->
335
+ <!--
336
+ Not recommended due to CBC's vulnerability to padding oracle attacks. Key material accessible from control plane host.
337
+ -->
329
338
由于 CBC 容易受到密文填塞攻击(Padding Oracle Attack),不推荐使用。密钥材料可从控制面主机访问。
330
339
</td>
331
340
</tr>
332
341
<tr>
333
342
<th rowspan="2" scope="row"><tt>aesgcm</tt></th>
334
343
<td>
335
- <!-- AES-GCM with random nonce -->
344
+ <!--
345
+ AES-GCM with random nonce
346
+ -->
336
347
带有随机数的 AES-GCM
337
348
</td>
338
349
<td>
339
- <!-- Must be rotated every 200,000 writes -->
350
+ <!--
351
+ Must be rotated every 200,000 writes
352
+ -->
340
353
每写入 200k 次后必须轮换
341
354
</td>
342
355
<td><!-- Fastest -->最快</td>
343
356
<td><!-- 16, 24, or 32-byte -->16、24 或者 32 字节</td>
344
357
</tr>
345
358
<tr>
346
359
<td colspan="4">
347
- <!-- Not recommended for use except when an automated key rotation scheme is implemented. Key material accessible from control plane host. -->
360
+ <!--
361
+ Not recommended for use except when an automated key rotation scheme is implemented. Key material accessible from control plane host.
362
+ -->
348
363
不建议使用,除非实施了自动密钥轮换方案。密钥材料可从控制面主机访问。
349
364
</td>
350
365
</tr>
351
366
<tr>
352
367
<th rowspan="2" scope="row"><tt>kms</tt> v1 <em><!--(deprecated since Kubernetes v1.28)-->(自 Kubernetes 1.28 起弃用)</em></th>
353
368
<td>
354
- <!-- Uses envelope encryption scheme with DEK per resource. -->
369
+ <!--
370
+ Uses envelope encryption scheme with DEK per resource.
371
+ -->
355
372
针对每个资源使用不同的 DEK 来完成信封加密。
356
373
</td>
357
374
<td><!-- Strongest -->最强</td>
@@ -380,7 +397,9 @@ Kubernetes 静态数据加密的 Provider
380
397
<tr>
381
398
<th rowspan="2" scope="row"><tt>kms</tt> v2 <em>(beta)</em></th>
382
399
<td>
383
- <!-- Uses envelope encryption scheme with DEK per API server. -->
400
+ <!--
401
+ Uses envelope encryption scheme with DEK per API server.
402
+ -->
384
403
针对每个 API 服务器使用不同的 DEK 来完成信封加密。
385
404
</td>
386
405
<td><!-- Strongest -->最强</td>
@@ -440,7 +459,7 @@ Kubernetes 静态数据加密的 Provider
440
459
Each provider supports multiple keys - the keys are tried in order for decryption, and if the provider
441
460
is the first provider, the first key is used for encryption.
442
461
-->
443
- 每个 provider 都支持多个密钥 - 在解密时会按顺序使用密钥,如果是第一个 provider ,则第一个密钥用于加密。
462
+ 每个 Provider 都支持多个密钥 - 在解密时会按顺序使用密钥,如果是第一个 Provider ,则第一个密钥用于加密。
444
463
445
464
{{< caution >}}
446
465
<!--
@@ -574,7 +593,7 @@ To create a new Secret, perform the following steps:
574
593
...
575
594
- name: enc # 增加这一行
576
595
mountPath: /etc/kubernetes/enc # 增加这一行
577
- readonly : true # 增加这一行
596
+ readOnly : true # 增加这一行
578
597
...
579
598
volumes:
580
599
...
@@ -600,31 +619,54 @@ permissions on your control-plane nodes so only the user who runs the `kube-apis
600
619
{{< /caution >}}
601
620
602
621
<!--
603
- # # Verifying that data is encrypted
622
+ # ## Reconfigure other control plane hosts {#api-server-config-update-more}
604
623
605
- Data is encrypted when written to etcd. After restarting your `kube-apiserver`, any newly created or
606
- updated Secret or other resource types configured in `EncryptionConfiguration` should be encrypted
607
- when stored. To check this, you can use the `etcdctl` command line
624
+ If you have multiple API servers in your cluster, you should deploy the
625
+ changes in turn to each API server.
626
+
627
+ Make sure that you use the **same** encryption configuration on each
628
+ control plane host.
629
+ -->
630
+ # ## 重新配置其他控制平面主机 {#api-server-config-update-more}
631
+
632
+ 如果你的集群中有多个 API 服务器,应轮流将更改部署到每个 API 服务器。
633
+
634
+ 确保在每个控制平面主机上使用**相同的**加密配置。
635
+
636
+ <!--
637
+ # ## Verify that newly written data is encrypted {#verifying-that-data-is-encrypted}
638
+
639
+ Data is encrypted when written to etcd. After restarting your `kube-apiserver`, any newly
640
+ created or updated Secret (or other resource kinds configured in `EncryptionConfiguration`)
641
+ should be encrypted when stored.
642
+
643
+ To check this, you can use the `etcdctl` command line
608
644
program to retrieve the contents of your secret data.
609
645
610
- 1. Create a new Secret called `secret1` in the `default` namespace :
646
+ This example shows how to check this for encrypting the Secret API.
611
647
-->
612
- # # 验证数据已被加密 {#verifying-that-data-is-encryped}
648
+ # ## 验证数据已被加密 {#verifying-that-data-is-encryped}
613
649
614
650
数据在写入 etcd 时会被加密。重新启动你的 `kube-apiserver` 后,任何新创建或更新的 Secret
615
- 或在 `EncryptionConfiguration` 中配置的其他资源类型都应在存储时被加密。
651
+ 或在 `EncryptionConfiguration` 中配置的其他资源类别都应在存储时被加密。
652
+
616
653
如果想要检查,你可以使用 `etcdctl` 命令行程序来检索你的 Secret 数据内容。
617
654
618
- 1. 创建一个新的 secret,名称为 `secret1`,命名空间为 `default`:
655
+ 以下示例演示了如何对加密 Secret API 进行检查。
656
+
657
+ <!--
658
+ 1. Create a new Secret called `secret1` in the `default` namespace :
659
+ -->
660
+ 1. 创建一个新的 Secret,名称为 `secret1`,命名空间为 `default`:
619
661
620
662
` ` ` shell
621
663
kubectl create secret generic secret1 -n default --from-literal=mykey=mydata
622
664
` ` `
623
665
624
666
<!--
625
- 1. Using the `etcdctl` command line, read that Secret out of etcd :
667
+ 1. Using the `etcdctl` command line tool , read that Secret out of etcd :
626
668
-->
627
- 2. 使用 `etcdctl` 命令行 ,从 etcd 中读取 Secret:
669
+ 2. 使用 `etcdctl` 命令行工具 ,从 etcd 中读取 Secret:
628
670
629
671
```
630
672
ETCDCTL_API=3 etcdctl get /registry/secrets/default/secret1 [ ...] | hexdump -C
@@ -686,38 +728,61 @@ program to retrieve the contents of your secret data.
686
728
```
687
729
688
730
<!--
689
- The output should contain `mykey: bXlkYXRh`, with contents of `mydata` encoded, check
731
+ The output should contain `mykey: bXlkYXRh`, with contents of `mydata` encoded using base64;
732
+ read
690
733
[decoding a Secret](/docs/tasks/configmap-secret/managing-secret-using-kubectl/#decoding-secret)
691
- to completely decode the Secret.
734
+ to learn how to completely decode the Secret.
692
735
-->
693
- 其输出应该包含 ` mykey: bXlkYXRh ` ,` mydata ` 的内容是被加密过的 ,
736
+ 其输出应该包含 ` mykey: bXlkYXRh ` ,其中 ` mydata ` 的内容使用 base64 进行加密 ,
694
737
请参阅[ 解密 Secret] ( /zh-cn/docs/tasks/configmap-secret/managing-secret-using-kubectl/#decoding-secret )
695
738
了解如何完全解码 Secret 内容。
696
739
697
740
<!--
698
- ## Ensure all Secrets are encrypted
741
+ ### Ensure all relevant data are encrypted {#ensure-all-secrets-are-encrypted}
742
+
743
+ It's often not enough to make sure that new objects get encrypted: you also want that
744
+ encryption to apply to the objects that are already stored.
699
745
700
- Since Secrets are encrypted on write, performing an update on a Secret will encrypt that content.
746
+ For this example, you have configured your cluster so that Secrets are encrypted on write.
747
+ Performing a replace operation for each Secret will encrypt that content at rest,
748
+ where the objects are unchanged.
749
+
750
+ You can make this change across all Secrets in your cluster:
701
751
-->
702
- ## 确保所有 Secret 都被加密 {#ensure-all-secrets-are-encrypted}
752
+ ### 确保所有相关数据都被加密 {#ensure-all-secrets-are-encrypted}
753
+
754
+ 仅仅确保新对象被加密通常是不够的:你还希望对已经存储的对象进行加密。
703
755
704
- 由于 Secret 是在写入时被加密,因此对 Secret 执行更新也会加密该内容。
756
+ 例如,你已经配置了集群,使得 Secret 在写入时进行加密。
757
+ 为每个 Secret 执行替换操作将加密那些对象保持不变的静态内容。
705
758
759
+ 你可以在集群中的所有 Secret 上进行此项变更:
760
+
761
+ <!--
762
+ # Run this as an administrator that can read and write all Secrets
763
+ -->
706
764
``` shell
765
+ # 以能够读写所有 Secret 的管理员身份运行此命令
707
766
kubectl get secrets --all-namespaces -o json | kubectl replace -f -
708
767
```
709
768
710
769
<!--
711
- The command above reads all Secrets and then updates them to apply server side encryption.
770
+ The command above reads all Secrets and then updates them with the same data, in order to
771
+ apply server side encryption.
712
772
-->
713
- 上面的命令读取所有 Secret,然后使用服务端加密来更新其内容 。
773
+ 上面的命令读取所有 Secret,然后使用相同的数据更新这些 Secret,以便应用服务端加密 。
714
774
715
775
{{< note >}}
716
776
<!--
717
777
If an error occurs due to a conflicting write, retry the command.
718
- For larger clusters, you may wish to subdivide the secrets by namespace or script an update.
778
+ It is safe to run that command more than once.
779
+
780
+ For larger clusters, you may wish to subdivide the Secrets by namespace,
781
+ or script an update.
719
782
-->
720
783
如果由于冲突写入而发生错误,请重试该命令。
784
+ 多次运行此命令是安全的。
785
+
721
786
对于较大的集群,你可能希望通过命名空间或更新脚本来对 Secret 进行划分。
722
787
{{< /note >}}
723
788
0 commit comments