|
8 | 8 | - [Non-Goals](#non-goals)
|
9 | 9 | - [Proposal](#proposal)
|
10 | 10 | - [Design Details](#design-details)
|
| 11 | + - [Sequence Diagram](#sequence-diagram) |
| 12 | + - [Encrypt Request](#encrypt-request) |
| 13 | + - [Decrypt Request](#decrypt-request) |
11 | 14 | - [Test Plan](#test-plan)
|
12 | 15 | - [Graduation Criteria](#graduation-criteria)
|
13 | 16 | - [Alpha](#alpha)
|
@@ -290,6 +293,58 @@ This `UID` field is included in the `EncryptRequest` and `DecryptRequest` of the
|
290 | 293 | 2. In addition to the `UID`, the kube-apiserver will also log non-sensitive metadata such as `name`, `namespace` and `GroupVersionResource` of the object that triggered the envelope operation.
|
291 | 294 | 2. Sent to the kms-plugin as part of the `EncryptRequest` and `DecryptRequest` structs.
|
292 | 295 |
|
| 296 | +### Sequence Diagram |
| 297 | + |
| 298 | +#### Encrypt Request |
| 299 | + |
| 300 | +```mermaid |
| 301 | +sequenceDiagram |
| 302 | + participant etcd |
| 303 | + participant kubeapiserver |
| 304 | + participant kmsplugin |
| 305 | + participant externalkms |
| 306 | + kubeapiserver->>kmsplugin: encrypt request |
| 307 | + alt using key hierarchy |
| 308 | + kmsplugin->>kmsplugin: encrypt DEK with local KEK |
| 309 | + kmsplugin->>externalkms: encrypt local KEK with remote KEK |
| 310 | + externalkms->>kmsplugin: encrypted local KEK |
| 311 | + kmsplugin->>kmsplugin: cache encrypted local KEK |
| 312 | + kmsplugin->>kubeapiserver: return encrypt response <br/> {"cipher": "<encrypted DEK>", currentKeyID: "<remote KEK ID>", <br/> "metadata": {"kms.kubernetes.io/local-kek": "<encrypted local KEK>"}} |
| 313 | + else not using key hierarchy |
| 314 | + %% current behavior |
| 315 | + kmsplugin->>externalkms: encrypt DEK with remote KEK |
| 316 | + externalkms->>kmsplugin: encrypted DEK |
| 317 | + kmsplugin->>kubeapiserver: return encrypt response <br/> {"cipher": "<encrypted DEK>", currentKeyID: "<remote KEK ID>", "metadata": {}} |
| 318 | + end |
| 319 | + kubeapiserver->>etcd: store encrypt response and encrypted DEK |
| 320 | +``` |
| 321 | + |
| 322 | +#### Decrypt Request |
| 323 | + |
| 324 | +```mermaid |
| 325 | +sequenceDiagram |
| 326 | + participant kubeapiserver |
| 327 | + participant kmsplugin |
| 328 | + participant externalkms |
| 329 | + %% if local KEK in metadata, then using hierarchy |
| 330 | + alt encrypted local KEK is in metadata |
| 331 | + kubeapiserver->>kmsplugin: decrypt request <br/> {"cipher": "<encrypted DEK>", observedKeyID: "<currentKeyID gotten as part of EncryptResponse>", <br/> "metadata": {"kms.kubernetes.io/local-kek": "<encrypted local KEK>"}} |
| 332 | + alt encrypted local KEK in cache |
| 333 | + kmsplugin->>kmsplugin: decrypt DEK with local KEK |
| 334 | + else encrypted local KEK not in cache |
| 335 | + kmsplugin->>externalkms: decrypt local KEK with remote KEK |
| 336 | + externalkms->>kmsplugin: decrypted local KEK |
| 337 | + kmsplugin->>kmsplugin: decrypt DEK with local KEK |
| 338 | + kmsplugin->>kmsplugin: cache decrypted local KEK |
| 339 | + end |
| 340 | + kmsplugin->>kubeapiserver: return decrypt response <br/> {"plain": "<decrypted DEK>", currentKeyID: "<remote KEK ID>", <br/> "metadata": {"kms.kubernetes.io/local-kek": "<encrypted local KEK>"}} |
| 341 | + else encrypted local KEK is not in metadata |
| 342 | + kubeapiserver->>kmsplugin: decrypt request <br/> {"cipher": "<encrypted DEK>", observedKeyID: "<currentKeyID gotten as part of EncryptResponse>", <br/> "metadata": {}} |
| 343 | + kmsplugin->>externalkms: decrypt DEK with remote KEK (same behavior as today) |
| 344 | + externalkms->>kmsplugin: decrypted DEK |
| 345 | + kmsplugin->>kubeapiserver: return decrypt response <br/> {"plain": "<decrypted DEK>", currentKeyID: "<remote KEK ID>", <br/> "metadata": {}} |
| 346 | + end |
| 347 | +``` |
293 | 348 |
|
294 | 349 | ### Test Plan
|
295 | 350 |
|
|
0 commit comments