Skip to content

Commit eaf4c4e

Browse files
author
Tim Bannister
committed
Clarify how to ensure objects are encrypted
1 parent d1b4ef8 commit eaf4c4e

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

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

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -386,20 +386,32 @@ Your config file contains keys that can decrypt the contents in etcd, so you mus
386386
permissions on your control-plane nodes so only the user who runs the `kube-apiserver` can read it.
387387
{{< /caution >}}
388388

389-
## Verifying that data is encrypted
389+
### Reconfigure other control plane hosts {#api-server-config-update-more}
390390

391-
Data is encrypted when written to etcd. After restarting your `kube-apiserver`, any newly created or
392-
updated Secret or other resource types configured in `EncryptionConfiguration` should be encrypted
393-
when stored. To check this, you can use the `etcdctl` command line
391+
If you have multiple API servers in your cluster, you should deploy the
392+
changes in turn to each API server.
393+
394+
Make sure that you use the **same** encryption configuration on each
395+
control plane host.
396+
397+
### Verify that newly written data is encrypted {#verifying-that-data-is-encrypted}
398+
399+
Data is encrypted when written to etcd. After restarting your `kube-apiserver`, any newly
400+
created or updated Secret (or other resource kinds configured in `EncryptionConfiguration`)
401+
should be encrypted when stored.
402+
403+
To check this, you can use the `etcdctl` command line
394404
program to retrieve the contents of your secret data.
395405

406+
This example shows how to check this for encrypting the Secret API.
407+
396408
1. Create a new Secret called `secret1` in the `default` namespace:
397409

398410
```shell
399411
kubectl create secret generic secret1 -n default --from-literal=mykey=mydata
400412
```
401413

402-
1. Using the `etcdctl` command line, read that Secret out of etcd:
414+
1. Using the `etcdctl` command line tool, read that Secret out of etcd:
403415

404416
```
405417
ETCDCTL_API=3 etcdctl get /registry/secrets/default/secret1 [...] | hexdump -C
@@ -444,23 +456,36 @@ program to retrieve the contents of your secret data.
444456
kubectl get secret secret1 -n default -o yaml
445457
```
446458

447-
The output should contain `mykey: bXlkYXRh`, with contents of `mydata` encoded, check
459+
The output should contain `mykey: bXlkYXRh`, with contents of `mydata` encoded using base64;
460+
read
448461
[decoding a Secret](/docs/tasks/configmap-secret/managing-secret-using-kubectl/#decoding-secret)
449-
to completely decode the Secret.
462+
to learn how to completely decode the Secret.
463+
464+
### Ensure all relevant data are encrypted {#ensure-all-secrets-are-encrypted}
450465

451-
## Ensure all Secrets are encrypted
466+
It's often not enough to make sure that new objects get encrypted: you also want that
467+
encryption to apply to the objects that are already stored.
452468

453-
Since Secrets are encrypted on write, performing an update on a Secret will encrypt that content.
469+
For this example, you have configured your cluster so that Secrets are encrypted on write.
470+
Performing a replace operation for each Secret will encrypt that content at rest,
471+
where the objects are unchanged.
472+
473+
You can make this change across all Secrets in your cluster:
454474

455475
```shell
476+
# Run this as an administrator that can read and write all Secrets
456477
kubectl get secrets --all-namespaces -o json | kubectl replace -f -
457478
```
458479

459-
The command above reads all Secrets and then updates them to apply server side encryption.
480+
The command above reads all Secrets and then updates them with the same data, in order to
481+
apply server side encryption.
460482

461483
{{< note >}}
462484
If an error occurs due to a conflicting write, retry the command.
463-
For larger clusters, you may wish to subdivide the secrets by namespace or script an update.
485+
It is safe to run that command more than once.
486+
487+
For larger clusters, you may wish to subdivide the Secrets by namespace,
488+
or script an update.
464489
{{< /note >}}
465490

466491
## Rotating a decryption key

0 commit comments

Comments
 (0)