Skip to content

Commit

Permalink
[zh]sync encrypt-data.md
Browse files Browse the repository at this point in the history
  • Loading branch information
windsonsea committed Sep 27, 2022
1 parent 20d976a commit d27bf0b
Showing 1 changed file with 93 additions and 13 deletions.
106 changes: 93 additions & 13 deletions content/zh-cn/docs/tasks/administer-cluster/encrypt-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The configuration is provided as an API named
[`EncryptionConfiguration`](/docs/reference/config-api/apiserver-encryption.v1/).
An example configuration is provided below.
-->
## 配置并确定是否已启用静态数据加密
## 配置并确定是否已启用静态数据加密 {#configuration-and-determing-wheter-encryption-at-rest-is-already-enabled}

`kube-apiserver` 的参数 `--encryption-provider-config` 控制 API 数据在 etcd 中的加密方式。
该配置作为一个名为 [`EncryptionConfiguration`](/zh-cn/docs/reference/config-api/apiserver-encryption.v1/) 的 API 提供。
Expand All @@ -55,7 +55,7 @@ decrypt data stored in the etcd.
<!--
## Understanding the encryption at rest configuration.
-->
## 理解静态数据加密
## 理解静态数据加密 {#understanding-the-encryption-at-rest-configuration}

```yaml
apiVersion: apiserver.config.k8s.io/v1
Expand Down Expand Up @@ -184,7 +184,7 @@ retrieve the plaintext values, providing a higher level of security than locally
Create a new encryption config file:
-->
## 加密你的数据
## 加密你的数据 {#encrypting-you-data}

创建一个新的加密配置文件:

Expand Down Expand Up @@ -219,19 +219,67 @@ To create a new Secret, perform the following steps:
1. Place that value in the `secret` field of the `EncryptionConfiguration` struct.
1. Set the `--encryption-provider-config` flag on the `kube-apiserver` to point to
the location of the config file.
1. Restart your API server.
You will need to mount the new encryption config file to the `kube-apiserver` static pod. Here is an example on how to do that:
-->
2. 将这个值放入到 `EncryptionConfiguration` 结构体的 `secret` 字段中。
3. 设置 `kube-apiserver``--encryption-provider-config` 参数,将其指向配置文件所在位置。

你将需要把新的加密配置文件挂载到 `kube-apiserver` 静态 Pod。以下是这个操作的示例:

<!--
1. Save the new encryption config file to `/etc/kubernetes/enc/enc.yaml` on the control-plane node.
1. Edit the manifest for the `kube-apiserver` static pod: `/etc/kubernetes/manifests/kube-apiserver.yaml` similarly to this:
-->
1. 将新的加密配置文件保存到控制平面节点上的 `/etc/kubernetes/enc/enc.yaml`
2. 编辑 `kube-apiserver` 静态 Pod 的清单:`/etc/kubernetes/manifests/kube-apiserver.yaml`
代码范例如下:

```yaml
apiVersion: v1
kind: Pod
metadata:
annotations:
kubeadm.kubernetes.io/kube-apiserver.advertise-address.endpoint: 10.10.30.4:6443
creationTimestamp: null
labels:
component: kube-apiserver
tier: control-plane
name: kube-apiserver
namespace: kube-system
spec:
containers:
- command:
- kube-apiserver
...
- --encryption-provider-config=/etc/kubernetes/enc/enc.yaml # <-- 增加这一行
volumeMounts:
...
- name: enc # <-- 增加这一行
mountPath: /etc/kubernetes/enc # <-- 增加这一行
readonly: true # <-- 增加这一行
...
volumes:
...
- name: enc # <-- 增加这一行
hostPath: # <-- 增加这一行
path: /etc/kubernetes/enc # <-- 增加这一行
type: DirectoryOrCreate # <-- 增加这一行
...
```

<!--
1. Restart your API server.
-->
4. 重启你的 API 服务器。

{{< caution >}}
<!--
Your config file contains keys that can decrypt the contents in etcd, so you must properly restrict
permissions on your control-plane nodes so only the user who runs the `kube-apiserver` can read it.
-->
{{< caution >}}
你的配置文件包含可以解密 etcd 内容的密钥,因此你必须正确限制主控节点的访问权限,
以便只有能运行 kube-apiserver 的用户才能读取它。
你的配置文件包含可以解密 etcd 内容的密钥,因此你必须正确限制控制平面节点的访问权限,
以便只有能运行 `kube-apiserver` 的用户才能读取它。
{{< /caution >}}

<!--
Expand All @@ -243,7 +291,7 @@ program to retrieve the contents of your Secret.
1. Create a new Secret called `secret1` in the `default` namespace:
-->
## 验证数据已被加密
## 验证数据已被加密 {#verifying-that-data-is-encryped}

数据在写入 etcd 时会被加密。重新启动你的 `kube-apiserver` 后,任何新创建或更新的密码在存储时都应该被加密。
如果想要检查,你可以使用 `etcdctl` 命令行程序来检索你的加密内容。
Expand All @@ -268,6 +316,38 @@ program to retrieve the contents of your Secret.
-->
这里的 `[...]` 是用来连接 etcd 服务的额外参数。

<!--
For example:
-->
例如:

```shell
ETCDCTL_API=3 etcdctl \
--cacert=/etc/kubernetes/pki/etcd/ca.crt \
--cert=/etc/kubernetes/pki/etcd/server.crt \
--key=/etc/kubernetes/pki/etcd/server.key \
get /registry/secrets/default/secret1 | hexdump -C
```

<!--
The output is similar to this (abbreviated):
-->
输出类似于(有删减):

```hexdump
00000000 2f 72 65 67 69 73 74 72 79 2f 73 65 63 72 65 74 |/registry/secret|
00000010 73 2f 64 65 66 61 75 6c 74 2f 73 65 63 72 65 74 |s/default/secret|
00000020 31 0a 6b 38 73 3a 65 6e 63 3a 61 65 73 63 62 63 |1.k8s:enc:aescbc|
00000030 3a 76 31 3a 6b 65 79 31 3a c7 6c e7 d3 09 bc 06 |:v1:key1:.l.....|
00000040 25 51 91 e4 e0 6c e5 b1 4d 7a 8b 3d b9 c2 7c 6e |%Q...l..Mz.=..|n|
00000050 b4 79 df 05 28 ae 0d 8e 5f 35 13 2c c0 18 99 3e |.y..(..._5.,...>|
[...]
00000110 23 3a 0d fc 28 ca 48 2d 6b 2d 46 cc 72 0b 70 4c |#:..(.H-k-F.r.pL|
00000120 a5 fc 35 43 12 4e 60 ef bf 6f fe cf df 0b ad 1f |..5C.N`..o......|
00000130 82 c4 88 53 02 da 3e 66 ff 0a |...S..>f..|
0000013a
```

<!--
1. Verify the stored Secret is prefixed with `k8s:enc:aescbc:v1:` which indicates
the `aescbc` provider has encrypted the resulting data.
Expand Down Expand Up @@ -296,7 +376,7 @@ program to retrieve the contents of your Secret.
Since Secrets are encrypted on write, performing an update on a Secret will encrypt that content.
-->
## 确保所有 Secret 都被加密
## 确保所有 Secret 都被加密 {#ensure-all-secrets-are-encrypted}

由于 Secret 是在写入时被加密,因此对 Secret 执行更新也会加密该内容。

Expand Down Expand Up @@ -335,10 +415,10 @@ the presence of a highly-available deployment where multiple `kube-apiserver` pr
When running a single `kube-apiserver` instance, step 2 may be skipped.
-->
## 轮换解密密钥
## 轮换解密密钥 {#rotating-a-decryption-key}

在不发生停机的情况下更改 Secret 需要多步操作,特别是在有多个 `kube-apiserver` 进程正在运行的
高可用环境中
在不发生停机的情况下更改 Secret 需要多步操作,特别是在有多个 `kube-apiserver`
进程正在运行的高可用环境中

1. 生成一个新密钥并将其添加为所有服务器上当前提供程序的第二个密钥条目
1. 重新启动所有 `kube-apiserver` 进程以确保每台服务器都可以使用新密钥进行解密
Expand All @@ -356,7 +436,7 @@ When running a single `kube-apiserver` instance, step 2 may be skipped.
To disable encryption at rest, place the `identity` provider as the first entry in the config
and restart all `kube-apiserver` processes.
-->
## 解密所有数据
## 解密所有数据 {#decrypting-all-data}

要禁用静态加密,请将 `identity` provider
作为配置中的第一个条目并重新启动所有 `kube-apiserver` 进程。
Expand Down

0 comments on commit d27bf0b

Please sign in to comment.