Skip to content

Commit b6348e7

Browse files
authored
Merge pull request #20922 from sftim/20200512_fix_markdown_encryption_at_rest
Fix shortcodes in “Encrypting Secret Data at Rest”
2 parents 0935447 + 0cd2278 commit b6348e7

File tree

1 file changed

+28
-22
lines changed

1 file changed

+28
-22
lines changed

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

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ but not both in the same item).
6262

6363
The first provider in the list is used to encrypt resources going into storage. When reading
6464
resources from storage each provider that matches the stored data attempts to decrypt the data in
65-
order. If no provider can read the stored data due to a mismatch in format or secret key, an error
66-
is returned which prevents clients from accessing that resource.
65+
order. If no provider can read the stored data due to a mismatch in format or secret key, an error
66+
is returned which prevents clients from accessing that resource.
6767

6868
{{< caution >}}
69-
**IMPORTANT:** If any resource is not readable via the encryption config (because keys were changed),
70-
the only recourse is to delete that key from the underlying etcd directly. Calls that attempt to
69+
**IMPORTANT:** If any resource is not readable via the encryption config (because keys were changed),
70+
the only recourse is to delete that key from the underlying etcd directly. Calls that attempt to
7171
read that resource will fail until it is deleted or a valid decryption key is provided.
7272
{{< /caution >}}
7373

@@ -117,9 +117,9 @@ To create a new secret perform the following steps:
117117

118118
1. Generate a 32 byte random key and base64 encode it. If you're on Linux or macOS, run the following command:
119119

120-
```
121-
head -c 32 /dev/urandom | base64
122-
```
120+
```shell
121+
head -c 32 /dev/urandom | base64
122+
```
123123

124124
2. Place that value in the secret field.
125125
3. Set the `--encryption-provider-config` flag on the `kube-apiserver` to point to the location of the config file.
@@ -138,39 +138,42 @@ program to retrieve the contents of your secret.
138138

139139
1. Create a new secret called `secret1` in the `default` namespace:
140140

141-
```
142-
kubectl create secret generic secret1 -n default --from-literal=mykey=mydata
143-
```
141+
```shell
142+
kubectl create secret generic secret1 -n default --from-literal=mykey=mydata
143+
```
144144

145145
2. Using the etcdctl commandline, read that secret out of etcd:
146146

147-
```
148-
   ETCDCTL_API=3 etcdctl get /registry/secrets/default/secret1 [...] | hexdump -C
149-
```
147+
`ETCDCTL_API=3 etcdctl get /registry/secrets/default/secret1 [...] | hexdump -C`
148+
149+
where `[...]` must be the additional arguments for connecting to the etcd server.
150+
151+
3. Verify the stored secret is prefixed with `k8s:enc:aescbc:v1:` which indicates the `aescbc` provider has encrypted the resulting data.
150152

151-
where `[...]` must be the additional arguments for connecting to the etcd server.
152-
3. Verify the stored secret is prefixed with `k8s:enc:aescbc:v1:` which indicates the `aescbc` provider has encrypted the resulting data.
153153
4. Verify the secret is correctly decrypted when retrieved via the API:
154154

155-
```
156-
kubectl describe secret secret1 -n default
157-
```
155+
```shell
156+
kubectl describe secret secret1 -n default
157+
```
158158

159-
should match `mykey: bXlkYXRh`, mydata is encoded, check [decoding a secret](/docs/concepts/configuration/secret#decoding-a-secret) to
160-
completely decode the secret.
159+
should match `mykey: bXlkYXRh`, mydata is encoded, check [decoding a secret](/docs/concepts/configuration/secret#decoding-a-secret) to
160+
completely decode the secret.
161161

162162

163163
## Ensure all secrets are encrypted
164164

165165
Since secrets are encrypted on write, performing an update on a secret will encrypt that content.
166166

167-
```
167+
```shell
168168
kubectl get secrets --all-namespaces -o json | kubectl replace -f -
169169
```
170170

171171
The command above reads all secrets and then updates them to apply server side encryption.
172+
173+
{{< note >}}
172174
If an error occurs due to a conflicting write, retry the command.
173175
For larger clusters, you may wish to subdivide the secrets by namespace or script an update.
176+
{{< /note >}}
174177

175178

176179
## Rotating a decryption key
@@ -206,7 +209,10 @@ resources:
206209
secret: <BASE 64 ENCODED SECRET>
207210
```
208211

209-
and restart all `kube-apiserver` processes. Then run the command `kubectl get secrets --all-namespaces -o json | kubectl replace -f -`
212+
and restart all `kube-apiserver` processes. Then run:
213+
```shell
214+
kubectl get secrets --all-namespaces -o json | kubectl replace -f -
215+
```
210216
to force all secrets to be decrypted.
211217

212218
{{% /capture %}}

0 commit comments

Comments
 (0)