@@ -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,33 +138,33 @@ 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
@@ -206,7 +206,10 @@ resources:
206
206
secret: <BASE 64 ENCODED SECRET>
207
207
` ` `
208
208
209
- and restart all ` kube-apiserver ` processes. Then run the command ` kubectl get secrets --all-namespaces -o json | kubectl replace -f - `
209
+ and restart all `kube-apiserver` processes. Then run :
210
+ ` ` ` shell
211
+ kubectl get secrets --all-namespaces -o json | kubectl replace -f -
212
+ ` ` `
210
213
to force all secrets to be decrypted.
211
214
212
215
{{% /capture %}}
0 commit comments