Skip to content

Commit e4628f1

Browse files
committed
machine_webhook: Support TDX confidential computing on GCP
Apart from AMD {SEV,SEV-SNP}, Intel TDX confidential computing machines can be provisioned in GCP. Allow such configurations in the machine webhooks.
1 parent b292ed4 commit e4628f1

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

pkg/webhooks/machine_webhook.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ const (
227227
// reference: https://cloud.google.com/compute/confidential-vm/docs/os-and-machine-type#machine-type
228228
var gcpConfidentialTypeMachineSeriesSupportingSEV = []string{"n2d", "c2d", "c3d"}
229229
var gcpConfidentialTypeMachineSeriesSupportingSEVSNP = []string{"n2d"}
230+
var gcpConfidentialTypeMachineSeriesSupportingTDX = []string{"c3"}
230231

231232
// defaultInstanceTypeForCloudProvider returns the default instance type for the given cloud provider and architecture.
232233
// If the cloud provider is not supported, an empty string is returned.
@@ -1339,10 +1340,17 @@ func validateGCPConfidentialComputing(providerSpec *machinev1beta1.GCPMachinePro
13391340
fmt.Sprintf("ConfidentialCompute %s requires a machine type in the following series: %s", providerSpec.ConfidentialCompute, strings.Join(gcpConfidentialTypeMachineSeriesSupportingSEVSNP, `,`))),
13401341
)
13411342
}
1343+
case machinev1beta1.ConfidentialComputePolicyTDX:
1344+
if !slices.Contains(gcpConfidentialTypeMachineSeriesSupportingTDX, machineSeries) {
1345+
errs = append(errs, field.Invalid(field.NewPath("providerSpec", "machineType"),
1346+
providerSpec.MachineType,
1347+
fmt.Sprintf("ConfidentialCompute %s requires a machine type in the following series: %s", providerSpec.ConfidentialCompute, strings.Join(gcpConfidentialTypeMachineSeriesSupportingTDX, `,`))),
1348+
)
1349+
}
13421350
default:
13431351
errs = append(errs, field.Invalid(field.NewPath("providerSpec", "confidentialCompute"),
13441352
providerSpec.ConfidentialCompute,
1345-
fmt.Sprintf("ConfidentialCompute must be %s, %s, %s, or %s", machinev1beta1.ConfidentialComputePolicyEnabled, machinev1beta1.ConfidentialComputePolicyDisabled, machinev1beta1.ConfidentialComputePolicySEV, machinev1beta1.ConfidentialComputePolicySEVSNP)),
1353+
fmt.Sprintf("ConfidentialCompute must be %s, %s, %s, %s, or %s", machinev1beta1.ConfidentialComputePolicyEnabled, machinev1beta1.ConfidentialComputePolicyDisabled, machinev1beta1.ConfidentialComputePolicySEV, machinev1beta1.ConfidentialComputePolicySEVSNP, machinev1beta1.ConfidentialComputePolicyTDX)),
13461354
)
13471355
}
13481356
}

pkg/webhooks/machine_webhook_test.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3805,7 +3805,7 @@ func TestValidateGCPProviderSpec(t *testing.T) {
38053805
p.OnHostMaintenance = machinev1beta1.TerminateHostMaintenanceType
38063806
},
38073807
expectedOk: false,
3808-
expectedError: "providerSpec.confidentialCompute: Invalid value: \"invalid-value\": ConfidentialCompute must be Enabled, Disabled, AMDEncryptedVirtualization, or AMDEncryptedVirtualizationNestedPaging",
3808+
expectedError: "providerSpec.confidentialCompute: Invalid value: \"invalid-value\": ConfidentialCompute must be Enabled, Disabled, AMDEncryptedVirtualization, AMDEncryptedVirtualizationNestedPaging, or IntelTrustedDomainExtensions",
38093809
},
38103810
{
38113811
testCase: "with ConfidentialCompute enabled while onHostMaintenance is set to Migrate",
@@ -3890,6 +3890,37 @@ func TestValidateGCPProviderSpec(t *testing.T) {
38903890
expectedOk: false,
38913891
expectedError: "providerSpec.onHostMaintenance: Invalid value: \"Migrate\": ConfidentialCompute AMDEncryptedVirtualizationNestedPaging requires OnHostMaintenance to be set to Terminate, the current value is: Migrate",
38923892
},
3893+
{
3894+
testCase: "with ConfidentialCompute IntelTrustedDomainExtensions and an unsupported machine",
3895+
modifySpec: func(p *machinev1beta1.GCPMachineProviderSpec) {
3896+
p.ConfidentialCompute = machinev1beta1.ConfidentialComputePolicyTDX
3897+
p.OnHostMaintenance = machinev1beta1.TerminateHostMaintenanceType
3898+
p.MachineType = "c3d-standard-4"
3899+
},
3900+
expectedOk: false,
3901+
expectedError: "providerSpec.machineType: Invalid value: \"c3d-standard-4\": ConfidentialCompute IntelTrustedDomainExtensions requires a machine type in the following series: c3",
3902+
},
3903+
{
3904+
testCase: "with ConfidentialCompute IntelTrustedDomainExtensions and a supported machine",
3905+
modifySpec: func(p *machinev1beta1.GCPMachineProviderSpec) {
3906+
p.ConfidentialCompute = machinev1beta1.ConfidentialComputePolicyTDX
3907+
p.OnHostMaintenance = machinev1beta1.TerminateHostMaintenanceType
3908+
p.MachineType = "c3-standard-4"
3909+
},
3910+
expectedOk: true,
3911+
expectedError: "",
3912+
},
3913+
{
3914+
testCase: "with ConfidentialCompute IntelTrustedDomainExtensions and onHostMaintenance set to Migrate",
3915+
modifySpec: func(p *machinev1beta1.GCPMachineProviderSpec) {
3916+
p.ConfidentialCompute = machinev1beta1.ConfidentialComputePolicyTDX
3917+
p.OnHostMaintenance = machinev1beta1.MigrateHostMaintenanceType
3918+
p.MachineType = "c3-standard-4"
3919+
p.GPUs = []machinev1beta1.GCPGPUConfig{}
3920+
},
3921+
expectedOk: false,
3922+
expectedError: "providerSpec.onHostMaintenance: Invalid value: \"Migrate\": ConfidentialCompute IntelTrustedDomainExtensions requires OnHostMaintenance to be set to Terminate, the current value is: Migrate",
3923+
},
38933924
{
38943925
testCase: "with GPUs and Migrate onHostMaintenance",
38953926
modifySpec: func(p *machinev1beta1.GCPMachineProviderSpec) {

0 commit comments

Comments
 (0)