@@ -142,6 +142,45 @@ To create a new Secret, perform the following steps:
142
142
1. Place that value in the `secret` field of the `EncryptionConfiguration` struct.
143
143
1. Set the `--encryption-provider-config` flag on the `kube-apiserver` to point to
144
144
the location of the config file.
145
+
146
+ 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 :
147
+
148
+ 1. Save the new encryption config file to `/etc/kubernetes/enc/enc.yaml` on the control-plane node.
149
+ 1. Edit the manifest for the `kube-apiserver` static pod : ` /etc/kubernetes/manifests/kube-apiserver.yaml` similarly to this:
150
+
151
+ ` ` ` yaml
152
+ apiVersion: v1
153
+ kind: Pod
154
+ metadata:
155
+ annotations:
156
+ kubeadm.kubernetes.io/kube-apiserver.advertise-address.endpoint: 10.10.30.4:6443
157
+ creationTimestamp: null
158
+ labels:
159
+ component: kube-apiserver
160
+ tier: control-plane
161
+ name: kube-apiserver
162
+ namespace: kube-system
163
+ spec:
164
+ containers:
165
+ - command:
166
+ - kube-apiserver
167
+ ...
168
+ - --encryption-provider-config=/etc/kubernetes/enc/enc.yaml # <-- add this line
169
+ volumeMounts:
170
+ ...
171
+ - name: enc # <-- add this line
172
+ mountPath: /etc/kubernetes/enc # <-- add this line
173
+ readonly: true # <-- add this line
174
+ ...
175
+ volumes:
176
+ ...
177
+ - name: enc # <-- add this line
178
+ hostPath: # <-- add this line
179
+ path: /etc/kubernetes/enc # <-- add this line
180
+ type: DirectoryOrCreate # <-- add this line
181
+ ...
182
+ ` ` `
183
+
145
184
1. Restart your API server.
146
185
147
186
{{< caution >}}
@@ -167,13 +206,39 @@ program to retrieve the contents of your Secret.
167
206
168
207
where `[...]` must be the additional arguments for connecting to the etcd server.
169
208
209
+ For example :
210
+
211
+ ` ` ` shell
212
+ ETCDCTL_API=3 etcdctl \
213
+ --cacert=/etc/kubernetes/pki/etcd/ca.crt \
214
+ --cert=/etc/kubernetes/pki/etcd/server.crt \
215
+ --key=/etc/kubernetes/pki/etcd/server.key \
216
+ get /registry/secrets/default/secret1 | hexdump -C
217
+ ` ` `
218
+
219
+ The output is similar to this (abbreviated) :
220
+
221
+ ` ` ` hexdump
222
+ 00000000 2f 72 65 67 69 73 74 72 79 2f 73 65 63 72 65 74 |/registry/secret|
223
+ 00000010 73 2f 64 65 66 61 75 6c 74 2f 73 65 63 72 65 74 |s/default/secret|
224
+ 00000020 31 0a 6b 38 73 3a 65 6e 63 3a 61 65 73 63 62 63 |1.k8s:enc:aescbc|
225
+ 00000030 3a 76 31 3a 6b 65 79 31 3a c7 6c e7 d3 09 bc 06 |:v1:key1:.l.....|
226
+ 00000040 25 51 91 e4 e0 6c e5 b1 4d 7a 8b 3d b9 c2 7c 6e |%Q...l..Mz.=..|n|
227
+ 00000050 b4 79 df 05 28 ae 0d 8e 5f 35 13 2c c0 18 99 3e |.y..(..._5.,...>|
228
+ [...]
229
+ 00000110 23 3a 0d fc 28 ca 48 2d 6b 2d 46 cc 72 0b 70 4c |#:..(.H-k-F.r.pL|
230
+ 00000120 a5 fc 35 43 12 4e 60 ef bf 6f fe cf df 0b ad 1f |..5C.N` ..o......|
231
+ 00000130 82 c4 88 53 02 da 3e 66 ff 0a |...S..>f..|
232
+ 0000013a
233
+ ```
234
+
170
235
1 . Verify the stored Secret is prefixed with ` k8s:enc:aescbc:v1: ` which indicates
171
236
the ` aescbc ` provider has encrypted the resulting data.
172
237
173
238
1 . Verify the Secret is correctly decrypted when retrieved via the API:
174
239
175
240
``` shell
176
- kubectl describe secret secret1 -n default
241
+ kubectl get secret secret1 -n default -o yaml
177
242
```
178
243
179
244
The output should contain ` mykey: bXlkYXRh ` , with contents of ` mydata ` encoded, check
0 commit comments