@@ -62,12 +62,12 @@ but not both in the same item).
62
62
63
63
The first provider in the list is used to encrypt resources going into storage. When reading
64
64
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.
67
67
68
68
{{< 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
71
71
read that resource will fail until it is deleted or a valid decryption key is provided.
72
72
{{< /caution >}}
73
73
@@ -117,9 +117,9 @@ To create a new secret perform the following steps:
117
117
118
118
1. Generate a 32 byte random key and base64 encode it. If you're on Linux or macOS, run the following command :
119
119
120
- ` ` `
121
- head -c 32 /dev/urandom | base64
122
- ` ` `
120
+ ` ` ` shell
121
+ head -c 32 /dev/urandom | base64
122
+ ` ` `
123
123
124
124
2. Place that value in the secret field.
125
125
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.
138
138
139
139
1. Create a new secret called `secret1` in the `default` namespace :
140
140
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
+ ` ` `
144
144
145
145
2. Using the etcdctl commandline, read that secret out of etcd :
146
146
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.
150
152
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.
153
153
4. Verify the secret is correctly decrypted when retrieved via the API :
154
154
155
- ` ` `
156
- kubectl describe secret secret1 -n default
157
- ` ` `
155
+ ` ` ` shell
156
+ kubectl describe secret secret1 -n default
157
+ ` ` `
158
158
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.
161
161
162
162
163
163
# # Ensure all secrets are encrypted
164
164
165
165
Since secrets are encrypted on write, performing an update on a secret will encrypt that content.
166
166
167
- ```
167
+ ` ` ` shell
168
168
kubectl get secrets --all-namespaces -o json | kubectl replace -f -
169
169
` ` `
170
170
171
171
The command above reads all secrets and then updates them to apply server side encryption.
172
+
173
+ {{< note >}}
172
174
If an error occurs due to a conflicting write, retry the command.
173
175
For larger clusters, you may wish to subdivide the secrets by namespace or script an update.
176
+ {{< /note >}}
174
177
175
178
176
179
# # Rotating a decryption key
@@ -206,7 +209,10 @@ resources:
206
209
secret: <BASE 64 ENCODED SECRET>
207
210
` ` `
208
211
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
+ ` ` `
210
216
to force all secrets to be decrypted.
211
217
212
218
{{% /capture %}}
0 commit comments