@@ -28,6 +28,7 @@ const (
28
28
encryptionPassphrasePrefix = "/dev/shm/disk-key"
29
29
)
30
30
31
+ // luksVolume struct holds the representative attributes related to a LUKS encrypted volume.
31
32
type luksVolume struct {
32
33
devicePath string
33
34
mappingName string
@@ -41,13 +42,27 @@ func must(err error) {
41
42
}
42
43
}
43
44
44
- // NewSetupEncryptedMountCmd creates a Cobra subcommand of the initializer to set up specified encrypted volumes .
45
+ // NewSetupEncryptedMountCmd creates a Cobra subcommand of the initializer to set up the specified encrypted LUKS volume .
45
46
func NewSetupEncryptedMountCmd () * cobra.Command {
46
47
cmd := & cobra.Command {
47
48
Use : "setupEncryptedMount -d [device-path] -m [mount-point]" ,
48
- Short : "" ,
49
- Long : "" ,
50
- RunE : setupEncryptedMount ,
49
+ Short : "setupEncryptedMount on block device at [device-path] with decrypted mapper device at [mount-point]" ,
50
+ Long : `Set up an LUKS encrypted VolumeMount on the provided VolumeDevice
51
+ located at the specified [device-path] and mount the decrypted mapper
52
+ device to the provided [mount-point].
53
+
54
+ In certain deployments, we require a persistent volume claim configured
55
+ as block storage to be encrypted by the initializer binary.
56
+ Therefore we expose the defined PVC as a block VolumeDevice to our
57
+ initializer container. This allows the initializer to setup the
58
+ encryption on the block device located at [device-path] using cryptsetup,
59
+ the encryption passphrase is derived from the UUID of the LUKS formatted
60
+ block device and the current workload secret.
61
+
62
+ The mapped decrypted block device can then be shared with other containers
63
+ on the pod by setting up a shared VolumeMount on the specified [mount-point],
64
+ where the mapper device will be mounted to.` ,
65
+ RunE : setupEncryptedMount ,
51
66
}
52
67
cmd .Flags ().StringP ("device-path" , "d" , "/dev/csi0" , "path to the volume device to be encrypted" )
53
68
cmd .Flags ().StringP ("mount-point" , "m" , "/state" , "mount point of decrypted mapper device" )
@@ -90,7 +105,6 @@ func setupEncryptedMount(cmd *cobra.Command, _ []string) error {
90
105
}
91
106
ctx := cmd .Context ()
92
107
if ! isLuks (ctx , logger , luksVolume .devicePath ) {
93
- // TODO(jmxnzo) might just use stdin instead for the initial passphrase generation
94
108
if err := createInitPassphrase (tmpPassphrase ); err != nil {
95
109
return err
96
110
}
@@ -228,7 +242,6 @@ func createEncryptionPassphrase(ctx context.Context, luksVolume *luksVolume, wor
228
242
if err != nil {
229
243
return fmt .Errorf ("reading workload secret: %w" , err )
230
244
}
231
- print (string (workloadSecretBytes ))
232
245
// Using UUID of the LUKS device ensures to not derive the same encryption key for multiple devices,
233
246
// still allowing reconstruction when UUID of device is known.
234
247
err = os .WriteFile (luksVolume .encryptionPassphrase , []byte (blk .UUID + string (workloadSecretBytes )), 0o644 )
0 commit comments