Skip to content

Commit 9f8b35d

Browse files
author
Tim Bannister
committed
Redo API encryption at rest explanation
- Explain importance of protecting keys and other material that can be used to decrypt data in etcd - Revise the explanation for a non-KMS setup example
1 parent 47c026a commit 9f8b35d

File tree

1 file changed

+74
-14
lines changed

1 file changed

+74
-14
lines changed

content/en/docs/tasks/administer-cluster/encrypt-data.md

Lines changed: 74 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,71 @@ Using envelope encryption creates dependence on the key encryption key, which is
311311
In the KMS case, an attacker who intends to get unauthorised access to the plaintext
312312
values would need to compromise etcd **and** the third-party KMS provider.
313313

314-
## Write an encryption configuration file
314+
### Protection for encryption keys
315+
316+
You should take appropriate measures to protect the confidential information that allows decryption,
317+
whether that is a local encryption key, or an authentication token that allows the API server to
318+
call KMS.
319+
320+
Even when you rely on a provider to manage the use and lifecycle of the main encryption key (or keys), you are still responsible
321+
for making sure that access controls and other security measures for the managed encryption service are
322+
appropriate for your security needs.
323+
324+
## Encrypt your data {#encrypting-your-data}
325+
326+
{{< caution >}}
327+
Storing the raw encryption key in the EncryptionConfig only moderately improves your security posture,
328+
compared to no encryption.
329+
330+
For additional secrecy, consider using the `kms` provider as this relies on keys held outside your
331+
Kubernetes cluster. Implementations of `kms` can work with hardware security modules or with
332+
encryption services managed by your cloud provider.
333+
{{< /caution >}}
334+
335+
### Generate the encryption key {#generate-key-no-kms}
336+
337+
_These instructions explain how to set up non-KMS encryption. You can use these as a guide
338+
to how you would configure KMS encryption; however, the specific details of that depend
339+
on the (external) KMS integration that you are using._
340+
341+
Start by generating a new encryption key, and then encode it using base64:
342+
343+
{{< tabs name="generate_encryption_key" >}}
344+
{{% tab name="Linux" %}}
345+
Generate a 32-byte random key and base64 encode it. You can use this command:
346+
```shell
347+
head -c 32 /dev/urandom | base64
348+
```
349+
350+
You can use `/dev/hwrng` instead of `/dev/urandom` if you want to
351+
use your PC's built-in hardware entropy source. Not all Linux
352+
devices provide a hardware random generator.
353+
{{% /tab %}}
354+
{{% tab name="macOS" %}}
355+
<!-- localization note: this is similar to the Linux tab and the wording
356+
should match wherever the English text does -->
357+
Generate a 32-byte random key and base64 encode it. You can use this command:
358+
```shell
359+
head -c 32 /dev/urandom | base64
360+
```
361+
{{% /tab %}}
362+
{{% tab name="Windows" %}}
363+
Generate a 32-byte random key and base64 encode it. You can use this command:
364+
```powershell
365+
# Do not run this in a session where you have set a random number
366+
# generator seed.
367+
[Convert]::ToBase64String((1..32|%{[byte](Get-Random -Max 256)}))
368+
```
369+
{{% /tab %}}
370+
{{< /tabs >}}
371+
372+
373+
{{< note >}}
374+
Keep the encryption key confidential, including whilst you generate it and
375+
ideally even after you are no longer actively using it.
376+
{{< /note >}}
377+
378+
### Write an encryption configuration file
315379

316380
{{< caution >}}
317381
The encryption configuration file may contain keys that can decrypt content in etcd.
@@ -341,22 +405,15 @@ resources:
341405
# for example, during initial migration
342406
```
343407

344-
To create a new Secret, perform the following steps:
345-
346-
1. Generate a 32-byte random key and base64 encode it. If you're on Linux or macOS, run the following command:
347-
348-
```shell
349-
head -c 32 /dev/urandom | base64
350-
```
408+
To create a new encryption key (that does not use KMS), see
409+
[Generate the encryption key](#generate-key-no-kms).
351410

352-
1. Place that value in the `secret` field of the `EncryptionConfiguration` struct.
353-
1. Set the `--encryption-provider-config` flag on the `kube-apiserver` to point to
354-
the location of the config file.
411+
### Use the new encryption configuration file
355412

356-
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:
413+
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:
357414

358-
1. Save the new encryption config file to `/etc/kubernetes/enc/enc.yaml` on the control-plane node.
359-
1. Edit the manifest for the `kube-apiserver` static pod: `/etc/kubernetes/manifests/kube-apiserver.yaml` similarly to this:
415+
1. Save the new encryption config file to `/etc/kubernetes/enc/enc.yaml` on the control-plane node.
416+
1. Edit the manifest for the `kube-apiserver` static pod: `/etc/kubernetes/manifests/kube-apiserver.yaml` so that it is similar to:
360417

361418
```yaml
362419
---
@@ -403,6 +460,9 @@ Your config file contains keys that can decrypt the contents in etcd, so you mus
403460
permissions on your control-plane nodes so only the user who runs the `kube-apiserver` can read it.
404461
{{< /caution >}}
405462

463+
You now have encryption in place for **one** control plane host. A typical
464+
Kubernetes cluster has multiple control plane hosts, so there is more to do.
465+
406466
### Reconfigure other control plane hosts {#api-server-config-update-more}
407467

408468
If you have multiple API servers in your cluster, you should deploy the

0 commit comments

Comments
 (0)