Skip to content

Commit 3a228e8

Browse files
committed
Add support for AMD SEV-SNP instances
This commit adds support for AMD SEV-SNP instances, so users can utilize confidential computing technology on cluster nodes. Signed-off-by: Fangge Jin <[email protected]>
1 parent 483f3a9 commit 3a228e8

12 files changed

+283
-0
lines changed

api/v1beta1/awscluster_conversion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func (src *AWSCluster) ConvertTo(dstRaw conversion.Hub) error {
6363
dst.Status.Bastion.NetworkInterfaceType = restored.Status.Bastion.NetworkInterfaceType
6464
dst.Status.Bastion.CapacityReservationID = restored.Status.Bastion.CapacityReservationID
6565
dst.Status.Bastion.MarketType = restored.Status.Bastion.MarketType
66+
dst.Status.Bastion.CPUOptions = restored.Status.Bastion.CPUOptions
6667
}
6768
dst.Spec.Partition = restored.Spec.Partition
6869

api/v1beta1/awsmachine_conversion.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func (src *AWSMachine) ConvertTo(dstRaw conversion.Hub) error {
4545
dst.Spec.CapacityReservationID = restored.Spec.CapacityReservationID
4646
dst.Spec.MarketType = restored.Spec.MarketType
4747
dst.Spec.NetworkInterfaceType = restored.Spec.NetworkInterfaceType
48+
dst.Spec.CPUOptions = restored.Spec.CPUOptions
4849
if restored.Spec.ElasticIPPool != nil {
4950
if dst.Spec.ElasticIPPool == nil {
5051
dst.Spec.ElasticIPPool = &infrav1.ElasticIPPool{}
@@ -109,6 +110,7 @@ func (r *AWSMachineTemplate) ConvertTo(dstRaw conversion.Hub) error {
109110
dst.Spec.Template.Spec.CapacityReservationID = restored.Spec.Template.Spec.CapacityReservationID
110111
dst.Spec.Template.Spec.MarketType = restored.Spec.Template.Spec.MarketType
111112
dst.Spec.Template.Spec.NetworkInterfaceType = restored.Spec.Template.Spec.NetworkInterfaceType
113+
dst.Spec.Template.Spec.CPUOptions = restored.Spec.Template.Spec.CPUOptions
112114
if restored.Spec.Template.Spec.ElasticIPPool != nil {
113115
if dst.Spec.Template.Spec.ElasticIPPool == nil {
114116
dst.Spec.Template.Spec.ElasticIPPool = &infrav1.ElasticIPPool{}

api/v1beta1/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta2/awsmachine_types.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,28 @@ const (
7373
NetworkInterfaceTypeEFAWithENAInterface NetworkInterfaceType = NetworkInterfaceType("efa")
7474
)
7575

76+
// AWSConfidentialComputePolicy represents the confidential compute configuration for the AWS machine.
77+
type AWSConfidentialComputePolicy string
78+
79+
const (
80+
// AWSConfidentialComputePolicyDisabled disables confidential compute for the AWS machine.
81+
AWSConfidentialComputePolicyDisabled AWSConfidentialComputePolicy = "Disabled"
82+
// AWSConfidentialComputePolicySEVSNP sets AMD SEV-SNP as the VM instance's confidential computing technology of choice.
83+
AWSConfidentialComputePolicySEVSNP AWSConfidentialComputePolicy = "AmdSevSnp"
84+
)
85+
86+
// CPUOptions defines the cpu options for the instance.
87+
type CPUOptions struct {
88+
// ConfidentialCompute specifies whether confidential computing should be enabled for the instance,
89+
// and, if so, which confidential computing technology to use.
90+
// If set to Disabled, the instance will not use confidential computing.
91+
// If set to AMDSevSnp, the instance will be configured with AMD SEV-SNP.
92+
// If omitted, the platform will apply a default value — currently Disabled, but this may change over time.
93+
// +kubebuilder:validation:Enum=Disabled;AMDSevSnp
94+
// +optional
95+
ConfidentialCompute AWSConfidentialComputePolicy `json:"confidentialCompute,omitempty"`
96+
}
97+
7698
// AWSMachineSpec defines the desired state of an Amazon EC2 instance.
7799
// +kubebuilder:validation:XValidation:rule="!has(self.capacityReservationId) || !has(self.marketType) || self.marketType != 'Spot'",message="capacityReservationId may not be set when marketType is Spot"
78100
// +kubebuilder:validation:XValidation:rule="!has(self.capacityReservationId) || !has(self.spotMarketOptions)",message="capacityReservationId cannot be set when spotMarketOptions is specified"
@@ -233,6 +255,10 @@ type AWSMachineSpec struct {
233255
// If marketType is not specified and spotMarketOptions is provided, the marketType defaults to "Spot".
234256
// +optional
235257
MarketType MarketType `json:"marketType,omitempty"`
258+
259+
// cpuOptions is the set of cpu options for the instance
260+
// +optional
261+
CPUOptions *CPUOptions `json:"cpuOptions,omitempty"`
236262
}
237263

238264
// CloudInit defines options related to the bootstrapping systems where

api/v1beta2/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ type Instance struct {
273273
// If marketType is not specified and spotMarketOptions is provided, the marketType defaults to "Spot".
274274
// +optional
275275
MarketType MarketType `json:"marketType,omitempty"`
276+
277+
// The cpu options of the instance.
278+
CPUOptions *CPUOptions `json:"cpuOptions,omitempty"`
276279
}
277280

278281
// MarketType describes the market type of an Instance

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,21 @@ spec:
12141214
description: CapacityReservationID specifies the target Capacity
12151215
Reservation into which the instance should be launched.
12161216
type: string
1217+
cpuOptions:
1218+
description: The cpu options of the instance.
1219+
properties:
1220+
confidentialCompute:
1221+
description: |-
1222+
ConfidentialCompute specifies whether confidential computing should be enabled for the instance,
1223+
and, if so, which confidential computing technology to use.
1224+
If set to Disabled, the instance will not use confidential computing.
1225+
If set to AMDSevSnp, the instance will be configured with AMD SEV-SNP.
1226+
If omitted, the platform will apply a default value — currently Disabled, but this may change over time.
1227+
enum:
1228+
- Disabled
1229+
- AMDSevSnp
1230+
type: string
1231+
type: object
12171232
ebsOptimized:
12181233
description: Indicates whether the instance is optimized for Amazon
12191234
EBS I/O.
@@ -3395,6 +3410,21 @@ spec:
33953410
description: CapacityReservationID specifies the target Capacity
33963411
Reservation into which the instance should be launched.
33973412
type: string
3413+
cpuOptions:
3414+
description: The cpu options of the instance.
3415+
properties:
3416+
confidentialCompute:
3417+
description: |-
3418+
ConfidentialCompute specifies whether confidential computing should be enabled for the instance,
3419+
and, if so, which confidential computing technology to use.
3420+
If set to Disabled, the instance will not use confidential computing.
3421+
If set to AMDSevSnp, the instance will be configured with AMD SEV-SNP.
3422+
If omitted, the platform will apply a default value — currently Disabled, but this may change over time.
3423+
enum:
3424+
- Disabled
3425+
- AMDSevSnp
3426+
type: string
3427+
type: object
33983428
ebsOptimized:
33993429
description: Indicates whether the instance is optimized for Amazon
34003430
EBS I/O.

config/crd/bases/infrastructure.cluster.x-k8s.io_awsclusters.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,6 +2197,21 @@ spec:
21972197
description: CapacityReservationID specifies the target Capacity
21982198
Reservation into which the instance should be launched.
21992199
type: string
2200+
cpuOptions:
2201+
description: The cpu options of the instance.
2202+
properties:
2203+
confidentialCompute:
2204+
description: |-
2205+
ConfidentialCompute specifies whether confidential computing should be enabled for the instance,
2206+
and, if so, which confidential computing technology to use.
2207+
If set to Disabled, the instance will not use confidential computing.
2208+
If set to AMDSevSnp, the instance will be configured with AMD SEV-SNP.
2209+
If omitted, the platform will apply a default value — currently Disabled, but this may change over time.
2210+
enum:
2211+
- Disabled
2212+
- AMDSevSnp
2213+
type: string
2214+
type: object
22002215
ebsOptimized:
22012216
description: Indicates whether the instance is optimized for Amazon
22022217
EBS I/O.

config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,21 @@ spec:
674674
- ssm-parameter-store
675675
type: string
676676
type: object
677+
cpuOptions:
678+
description: cpuOptions is the set of cpu options for the instance
679+
properties:
680+
confidentialCompute:
681+
description: |-
682+
ConfidentialCompute specifies whether confidential computing should be enabled for the instance,
683+
and, if so, which confidential computing technology to use.
684+
If set to Disabled, the instance will not use confidential computing.
685+
If set to AMDSevSnp, the instance will be configured with AMD SEV-SNP.
686+
If omitted, the platform will apply a default value — currently Disabled, but this may change over time.
687+
enum:
688+
- Disabled
689+
- AMDSevSnp
690+
type: string
691+
type: object
677692
elasticIpPool:
678693
description: ElasticIPPool is the configuration to allocate Public
679694
IPv4 address (Elastic IP/EIP) from user-defined pool.

config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,22 @@ spec:
593593
- ssm-parameter-store
594594
type: string
595595
type: object
596+
cpuOptions:
597+
description: cpuOptions is the set of cpu options for the
598+
instance
599+
properties:
600+
confidentialCompute:
601+
description: |-
602+
ConfidentialCompute specifies whether confidential computing should be enabled for the instance,
603+
and, if so, which confidential computing technology to use.
604+
If set to Disabled, the instance will not use confidential computing.
605+
If set to AMDSevSnp, the instance will be configured with AMD SEV-SNP.
606+
If omitted, the platform will apply a default value — currently Disabled, but this may change over time.
607+
enum:
608+
- Disabled
609+
- AMDSevSnp
610+
type: string
611+
type: object
596612
elasticIpPool:
597613
description: ElasticIPPool is the configuration to allocate
598614
Public IPv4 address (Elastic IP/EIP) from user-defined pool.

0 commit comments

Comments
 (0)