Skip to content

Commit 26158f1

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 5f62ff6 commit 26158f1

12 files changed

+313
-0
lines changed

api/v1beta1/awscluster_conversion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ func (src *AWSCluster) ConvertTo(dstRaw conversion.Hub) error {
6565
dst.Status.Bastion.MarketType = restored.Status.Bastion.MarketType
6666
dst.Status.Bastion.HostAffinity = restored.Status.Bastion.HostAffinity
6767
dst.Status.Bastion.HostID = restored.Status.Bastion.HostID
68+
dst.Status.Bastion.CPUOptions = restored.Status.Bastion.CPUOptions
6869
}
6970
dst.Spec.Partition = restored.Spec.Partition
7071

api/v1beta1/awsmachine_conversion.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func (src *AWSMachine) ConvertTo(dstRaw conversion.Hub) error {
4747
dst.Spec.HostID = restored.Spec.HostID
4848
dst.Spec.HostAffinity = restored.Spec.HostAffinity
4949
dst.Spec.NetworkInterfaceType = restored.Spec.NetworkInterfaceType
50+
dst.Spec.CPUOptions = restored.Spec.CPUOptions
5051
if restored.Spec.ElasticIPPool != nil {
5152
if dst.Spec.ElasticIPPool == nil {
5253
dst.Spec.ElasticIPPool = &infrav1.ElasticIPPool{}
@@ -113,6 +114,7 @@ func (r *AWSMachineTemplate) ConvertTo(dstRaw conversion.Hub) error {
113114
dst.Spec.Template.Spec.HostID = restored.Spec.Template.Spec.HostID
114115
dst.Spec.Template.Spec.HostAffinity = restored.Spec.Template.Spec.HostAffinity
115116
dst.Spec.Template.Spec.NetworkInterfaceType = restored.Spec.Template.Spec.NetworkInterfaceType
117+
dst.Spec.Template.Spec.CPUOptions = restored.Spec.Template.Spec.CPUOptions
116118
if restored.Spec.Template.Spec.ElasticIPPool != nil {
117119
if dst.Spec.Template.Spec.ElasticIPPool == nil {
118120
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: 34 additions & 0 deletions
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=None;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, AmdSevSnp
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"
@@ -245,6 +274,11 @@ type AWSMachineSpec struct {
245274
// +optional
246275
// +kubebuilder:validation:Enum:=default;host
247276
HostAffinity *string `json:"hostAffinity,omitempty"`
277+
278+
// cpuOptions defines CPU-related settings for the instance, including the confidential computing policy.
279+
// If unset, no CPU options will be passed to the AWS platform and AWS default CPU options will be applied.
280+
// +optional
281+
CPUOptions CPUOptions `json:"cpuOptions,omitempty,omitzero"`
248282
}
249283

250284
// 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
@@ -285,6 +285,9 @@ type Instance struct {
285285
// HostID specifies the dedicated host on which the instance should be started.
286286
// +optional
287287
HostID *string `json:"hostID,omitempty"`
288+
289+
// The cpu options of the instance.
290+
CPUOptions CPUOptions `json:"cpuOptions,omitempty,omitzero"`
288291
}
289292

290293
// 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, AmdSevSnp
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+
- None
1236+
- AmdSevSnp
1237+
type: string
1238+
type: object
12171239
ebsOptimized:
12181240
description: Indicates whether the instance is optimized for Amazon
12191241
EBS I/O.
@@ -3410,6 +3432,28 @@ spec:
34103432
description: CapacityReservationID specifies the target Capacity
34113433
Reservation into which the instance should be launched.
34123434
type: string
3435+
cpuOptions:
3436+
description: The cpu options of the instance.
3437+
minProperties: 1
3438+
properties:
3439+
confidentialCompute:
3440+
description: |-
3441+
confidentialCompute specifies whether confidential computing should be enabled for the instance,
3442+
and, if so, which confidential computing technology to use.
3443+
Valid values are: None, AmdSevSnp
3444+
When set to None, confidential computing will be disabled for the instance.
3445+
When set to AmdSevSnp, AMD SEV-SNP will be used as the confidential computing technology for the instance.
3446+
In this case, ensure the following conditions are met:
3447+
1) The selected instance type supports AMD SEV-SNP.
3448+
2) The selected AWS region supports AMD SEV-SNP.
3449+
3) The selected AMI supports AMD SEV-SNP.
3450+
More details can be checked at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/sev-snp.html
3451+
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.
3452+
enum:
3453+
- None
3454+
- AmdSevSnp
3455+
type: string
3456+
type: object
34133457
ebsOptimized:
34143458
description: Indicates whether the instance is optimized for Amazon
34153459
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, AmdSevSnp
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+
- None
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, AmdSevSnp
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+
- None
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, AmdSevSnp
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+
- None
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)