Skip to content

Commit 94d842c

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 4df1908 commit 94d842c

12 files changed

+314
-1
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: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,35 @@ const (
7373
NetworkInterfaceTypeEFAWithENAInterface NetworkInterfaceType = NetworkInterfaceType("efa")
7474
)
7575

76+
// AWSConfidentialComputePolicy represents the confidential compute configuration for the instance.
77+
// +kubebuilder:validation:Enum=Disabled;AmdSevSnp
78+
type AWSConfidentialComputePolicy string
79+
80+
const (
81+
// AWSConfidentialComputePolicyNone disables confidential computing for the instance.
82+
AWSConfidentialComputePolicyNone AWSConfidentialComputePolicy = "None"
83+
// AWSConfidentialComputePolicySEVSNP enables AMD SEV-SNP as the confidential computing technology for the instance.
84+
AWSConfidentialComputePolicySEVSNP AWSConfidentialComputePolicy = "AmdSevSnp"
85+
)
86+
87+
// CPUOptions defines CPU-related settings for the instance, including the confidential computing policy.
88+
// +kubebuilder:validation:MinProperties=1
89+
type CPUOptions struct {
90+
// confidentialCompute specifies whether confidential computing should be enabled for the instance,
91+
// and, if so, which confidential computing technology to use.
92+
// Valid values are: None, AmdSev
93+
// When set to None, confidential computing will be disabled for the instance.
94+
// When set to AmdSevSnp, AMD SEV-SNP will be used as the confidential computing technology for the instance.
95+
// In this case, ensure the following conditions are met:
96+
// 1) The selected instance type supports AMD SEV-SNP.
97+
// 2) The selected AWS region supports AMD SEV-SNP.
98+
// 3) The selected AMI supports AMD SEV-SNP.
99+
// More details can be checked at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/sev-snp.html
100+
// When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change without notice. The current default is Disabled.
101+
// +optional
102+
ConfidentialCompute AWSConfidentialComputePolicy `json:"confidentialCompute,omitempty"`
103+
}
104+
76105
// AWSMachineSpec defines the desired state of an Amazon EC2 instance.
77106
// +kubebuilder:validation:XValidation:rule="!has(self.capacityReservationId) || !has(self.marketType) || self.marketType != 'Spot'",message="capacityReservationId may not be set when marketType is Spot"
78107
// +kubebuilder:validation:XValidation:rule="!has(self.capacityReservationId) || !has(self.spotMarketOptions)",message="capacityReservationId cannot be set when spotMarketOptions is specified"
@@ -233,6 +262,11 @@ type AWSMachineSpec struct {
233262
// If marketType is not specified and spotMarketOptions is provided, the marketType defaults to "Spot".
234263
// +optional
235264
MarketType MarketType `json:"marketType,omitempty"`
265+
266+
// cpuOptions defines CPU-related settings for the instance, including the confidential computing policy.
267+
// If unset, no CPU options will be passed to the AWS platform and AWS default CPU options will be applied.
268+
// +optional
269+
CPUOptions CPUOptions `json:"cpuOptions,omitempty,omitzero"`
236270
}
237271

238272
// CloudInit defines options related to the bootstrapping systems where
@@ -263,7 +297,7 @@ type CloudInit struct {
263297
}
264298

265299
// Ignition defines options related to the bootstrapping systems where Ignition is used.
266-
// For more information on Ignition configuration, see https://coreos.github.io/butane/specs/
300+
// For more informfation on Ignition configuration, see https://coreos.github.io/butane/specs/
267301
type Ignition struct {
268302
// Version defines which version of Ignition will be used to generate bootstrap data.
269303
//

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,omitzero"`
276279
}
277280

278281
// MarketType describes the market type of an Instance

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 17 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: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,28 @@ 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+
minProperties: 1
1220+
properties:
1221+
confidentialCompute:
1222+
description: |-
1223+
confidentialCompute specifies whether confidential computing should be enabled for the instance,
1224+
and, if so, which confidential computing technology to use.
1225+
Valid values are: None, AmdSev
1226+
When set to None, confidential computing will be disabled for the instance.
1227+
When set to AmdSevSnp, AMD SEV-SNP will be used as the confidential computing technology for the instance.
1228+
In this case, ensure the following conditions are met:
1229+
1) The selected instance type supports AMD SEV-SNP.
1230+
2) The selected AWS region supports AMD SEV-SNP.
1231+
3) The selected AMI supports AMD SEV-SNP.
1232+
More details can be checked at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/sev-snp.html
1233+
When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change without notice. The current default is Disabled.
1234+
enum:
1235+
- Disabled
1236+
- AmdSevSnp
1237+
type: string
1238+
type: object
12171239
ebsOptimized:
12181240
description: Indicates whether the instance is optimized for Amazon
12191241
EBS I/O.
@@ -3396,6 +3418,28 @@ spec:
33963418
description: CapacityReservationID specifies the target Capacity
33973419
Reservation into which the instance should be launched.
33983420
type: string
3421+
cpuOptions:
3422+
description: The cpu options of the instance.
3423+
minProperties: 1
3424+
properties:
3425+
confidentialCompute:
3426+
description: |-
3427+
confidentialCompute specifies whether confidential computing should be enabled for the instance,
3428+
and, if so, which confidential computing technology to use.
3429+
Valid values are: None, AmdSev
3430+
When set to None, confidential computing will be disabled for the instance.
3431+
When set to AmdSevSnp, AMD SEV-SNP will be used as the confidential computing technology for the instance.
3432+
In this case, ensure the following conditions are met:
3433+
1) The selected instance type supports AMD SEV-SNP.
3434+
2) The selected AWS region supports AMD SEV-SNP.
3435+
3) The selected AMI supports AMD SEV-SNP.
3436+
More details can be checked at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/sev-snp.html
3437+
When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change without notice. The current default is Disabled.
3438+
enum:
3439+
- Disabled
3440+
- AmdSevSnp
3441+
type: string
3442+
type: object
33993443
ebsOptimized:
34003444
description: Indicates whether the instance is optimized for Amazon
34013445
EBS I/O.

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,6 +2197,28 @@ 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+
minProperties: 1
2203+
properties:
2204+
confidentialCompute:
2205+
description: |-
2206+
confidentialCompute specifies whether confidential computing should be enabled for the instance,
2207+
and, if so, which confidential computing technology to use.
2208+
Valid values are: None, AmdSev
2209+
When set to None, confidential computing will be disabled for the instance.
2210+
When set to AmdSevSnp, AMD SEV-SNP will be used as the confidential computing technology for the instance.
2211+
In this case, ensure the following conditions are met:
2212+
1) The selected instance type supports AMD SEV-SNP.
2213+
2) The selected AWS region supports AMD SEV-SNP.
2214+
3) The selected AMI supports AMD SEV-SNP.
2215+
More details can be checked at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/sev-snp.html
2216+
When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change without notice. The current default is Disabled.
2217+
enum:
2218+
- Disabled
2219+
- AmdSevSnp
2220+
type: string
2221+
type: object
22002222
ebsOptimized:
22012223
description: Indicates whether the instance is optimized for Amazon
22022224
EBS I/O.

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,30 @@ spec:
674674
- ssm-parameter-store
675675
type: string
676676
type: object
677+
cpuOptions:
678+
description: |-
679+
cpuOptions defines CPU-related settings for the instance, including the confidential computing policy.
680+
If unset, no CPU options will be passed to the AWS platform and AWS default CPU options will be applied.
681+
minProperties: 1
682+
properties:
683+
confidentialCompute:
684+
description: |-
685+
confidentialCompute specifies whether confidential computing should be enabled for the instance,
686+
and, if so, which confidential computing technology to use.
687+
Valid values are: None, AmdSev
688+
When set to None, confidential computing will be disabled for the instance.
689+
When set to AmdSevSnp, AMD SEV-SNP will be used as the confidential computing technology for the instance.
690+
In this case, ensure the following conditions are met:
691+
1) The selected instance type supports AMD SEV-SNP.
692+
2) The selected AWS region supports AMD SEV-SNP.
693+
3) The selected AMI supports AMD SEV-SNP.
694+
More details can be checked at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/sev-snp.html
695+
When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change without notice. The current default is Disabled.
696+
enum:
697+
- Disabled
698+
- AmdSevSnp
699+
type: string
700+
type: object
677701
elasticIpPool:
678702
description: ElasticIPPool is the configuration to allocate Public
679703
IPv4 address (Elastic IP/EIP) from user-defined pool.

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,30 @@ spec:
593593
- ssm-parameter-store
594594
type: string
595595
type: object
596+
cpuOptions:
597+
description: |-
598+
cpuOptions defines CPU-related settings for the instance, including the confidential computing policy.
599+
If unset, no CPU options will be passed to the AWS platform and AWS default CPU options will be applied.
600+
minProperties: 1
601+
properties:
602+
confidentialCompute:
603+
description: |-
604+
confidentialCompute specifies whether confidential computing should be enabled for the instance,
605+
and, if so, which confidential computing technology to use.
606+
Valid values are: None, AmdSev
607+
When set to None, confidential computing will be disabled for the instance.
608+
When set to AmdSevSnp, AMD SEV-SNP will be used as the confidential computing technology for the instance.
609+
In this case, ensure the following conditions are met:
610+
1) The selected instance type supports AMD SEV-SNP.
611+
2) The selected AWS region supports AMD SEV-SNP.
612+
3) The selected AMI supports AMD SEV-SNP.
613+
More details can be checked at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/sev-snp.html
614+
When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change without notice. The current default is Disabled.
615+
enum:
616+
- Disabled
617+
- AmdSevSnp
618+
type: string
619+
type: object
596620
elasticIpPool:
597621
description: ElasticIPPool is the configuration to allocate
598622
Public IPv4 address (Elastic IP/EIP) from user-defined pool.

0 commit comments

Comments
 (0)