Skip to content

Commit 0465066

Browse files
committed
feat(config): add encryption field for userVolumes
Signed-off-by: budimanjojo <budimanjojo@gmail.com>
1 parent 94ff3f0 commit 0465066

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed

docs/docs/reference/configuration.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,11 @@ userVolumes:
533533
maxSize: 50GiB
534534
filesystem:
535535
type: xfs
536+
encryption:
537+
provider: luks2
538+
keys:
539+
- slot: 0
540+
tpm: {}
536541
```
537542
</summary></td>
538543
<td markdown="1" align="center">`nil`</td>
@@ -1102,6 +1107,22 @@ filesystem:
11021107
<td markdown="1" align="center">:negative_squared_cross_mark:</td>
11031108
</tr>
11041109

1110+
<tr markdown="1">
1111+
<td markdown="1">`encryption`</td>
1112+
<td markdown="1">[EncryptionSpec](#encryptionspec)</td>
1113+
<td markdown="1">Encryption spec of the volume config.<details><summary>*Show example*</summary>
1114+
```yaml
1115+
encryption:
1116+
provider: luks2
1117+
keys:
1118+
- slot: 0
1119+
tpm: {}
1120+
```
1121+
</details></td>
1122+
<td markdown="1" align="center">`nil`</td>
1123+
<td markdown="1" align="center">:negative_squared_cross_mark:</td>
1124+
</tr>
1125+
11051126
</table>
11061127

11071128
## NetworkRule
@@ -1215,3 +1236,7 @@ In addition to this, there's also a `skipEnvsubst` key that can be set to `true`
12151236
## FilesystemSpec
12161237

12171238
`FilesystemSpec` is type of upstream Talos <a href="https://www.talos.dev/v1.10/reference/configuration/block/uservolumeconfig/#UserVolumeConfig.filesystem" target="_blank">`block.ProvisioningSpec`</a>
1239+
1240+
## EncryptionSpec
1241+
1242+
`Encryption` is type of upstream Talos <a href="https://www.talos.dev/v1.10/reference/configuration/block/uservolumeconfig/#UserVolumeConfig.encryption" target="_blank">`block.EncryptionSpec`</a>

example/talconfig.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ nodes:
4040
maxSize: 50GiB
4141
filesystem:
4242
type: xfs
43+
encryption:
44+
provider: luks2
45+
keys:
46+
- slot: 0
47+
tpm: {}
48+
- slot: 1
49+
static:
50+
passphrase: topsecret
4351
- name: sata
4452
provisioning:
4553
diskSelector:

pkg/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ type UserVolume struct {
106106
Name string `yaml:"name" jsonschema:"description=Name of user volume config"`
107107
Provisioning block.ProvisioningSpec `yaml:"provisioning" jsonschema:"description=Provisioning spec of the user volume config"`
108108
Filesystem block.FilesystemSpec `yaml:"filesystem" jsonschema:"description=Filesystem spec of the user volume config"`
109+
Encryption block.EncryptionSpec `yaml:"encryption" jsonschema:"description=Encryption spec of the user volume config"`
109110
}
110111

111112
type Volume struct {

pkg/talos/uservolumeconfig.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func GenerateUserVolumeConfig(cfgs []*config.UserVolume, mode string) ([]*block.
4949
uvc.MetaName = uv.Name
5050
uvc.ProvisioningSpec = uv.Provisioning
5151
uvc.FilesystemSpec = uv.Filesystem
52+
uvc.EncryptionSpec = uv.Encryption
5253

5354
if _, err := uvc.Validate(m); err != nil {
5455
return nil, err

pkg/talos/uservolumeconfig_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ func TestGenerateNodeUserVolumeConfig(t *testing.T) {
2222
maxSize: 50GiB
2323
filesystem:
2424
type: xfs
25+
encryption:
26+
provider: luks2
27+
keys:
28+
- slot: 0
29+
tpm: {}
30+
- slot: 1
31+
static:
32+
passphrase: topsecret
2533
- name: ceph-data2
2634
provisioning:
2735
diskSelector:
@@ -42,6 +50,19 @@ func TestGenerateNodeUserVolumeConfig(t *testing.T) {
4250
expectedVolume1Filesystem := block.FilesystemSpec{
4351
FilesystemType: blocktype.FilesystemTypeXFS,
4452
}
53+
expectedVolume1Encryption := block.EncryptionSpec{
54+
EncryptionProvider: blocktype.EncryptionProviderLUKS2,
55+
EncryptionKeys: []block.EncryptionKey{
56+
{
57+
KeySlot: 0,
58+
KeyTPM: &block.EncryptionKeyTPM{},
59+
},
60+
{
61+
KeySlot: 1,
62+
KeyStatic: &block.EncryptionKeyStatic{KeyData: "topsecret"},
63+
},
64+
},
65+
}
4566
expectedVolume2Name := "ceph-data2"
4667
expectedVolume2Provisioning := block.ProvisioningSpec{
4768
DiskSelectorSpec: block.DiskSelector{
@@ -58,6 +79,7 @@ func TestGenerateNodeUserVolumeConfig(t *testing.T) {
5879
compare(result[0].Name(), expectedVolume1Name, t)
5980
compare(result[0].ProvisioningSpec, expectedVolume1Provisioning, t)
6081
compare(result[0].FilesystemSpec, expectedVolume1Filesystem, t)
82+
compare(result[0].EncryptionSpec, expectedVolume1Encryption, t)
6183
compare(result[1].Name(), expectedVolume2Name, t)
6284
compare(result[1].ProvisioningSpec, expectedVolume2Provisioning, t)
6385
}

0 commit comments

Comments
 (0)