Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/v1beta1/awscluster_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func (src *AWSCluster) ConvertTo(dstRaw conversion.Hub) error {
dst.Status.Bastion.NetworkInterfaceType = restored.Status.Bastion.NetworkInterfaceType
dst.Status.Bastion.AssignPrimaryIPv6 = restored.Status.Bastion.AssignPrimaryIPv6
dst.Status.Bastion.CapacityReservationID = restored.Status.Bastion.CapacityReservationID
dst.Status.Bastion.CapacityReservationResourceGroupARN = restored.Status.Bastion.CapacityReservationResourceGroupARN
dst.Status.Bastion.MarketType = restored.Status.Bastion.MarketType
dst.Status.Bastion.HostAffinity = restored.Status.Bastion.HostAffinity
dst.Status.Bastion.HostID = restored.Status.Bastion.HostID
Expand Down
2 changes: 2 additions & 0 deletions api/v1beta1/awsmachine_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func (src *AWSMachine) ConvertTo(dstRaw conversion.Hub) error {
dst.Spec.PrivateDNSName = restored.Spec.PrivateDNSName
dst.Spec.SecurityGroupOverrides = restored.Spec.SecurityGroupOverrides
dst.Spec.CapacityReservationID = restored.Spec.CapacityReservationID
dst.Spec.CapacityReservationResourceGroupARN = restored.Spec.CapacityReservationResourceGroupARN
dst.Spec.MarketType = restored.Spec.MarketType
dst.Spec.HostID = restored.Spec.HostID
dst.Spec.HostAffinity = restored.Spec.HostAffinity
Expand Down Expand Up @@ -116,6 +117,7 @@ func (r *AWSMachineTemplate) ConvertTo(dstRaw conversion.Hub) error {
dst.Spec.Template.Spec.PrivateDNSName = restored.Spec.Template.Spec.PrivateDNSName
dst.Spec.Template.Spec.SecurityGroupOverrides = restored.Spec.Template.Spec.SecurityGroupOverrides
dst.Spec.Template.Spec.CapacityReservationID = restored.Spec.Template.Spec.CapacityReservationID
dst.Spec.Template.Spec.CapacityReservationResourceGroupARN = restored.Spec.Template.Spec.CapacityReservationResourceGroupARN
dst.Spec.Template.Spec.MarketType = restored.Spec.Template.Spec.MarketType
dst.Spec.Template.Spec.HostID = restored.Spec.Template.Spec.HostID
dst.Spec.Template.Spec.HostAffinity = restored.Spec.Template.Spec.HostAffinity
Expand Down
2 changes: 2 additions & 0 deletions api/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions api/v1beta2/awsmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ const (
)

// AWSMachineSpec defines the desired state of an Amazon EC2 instance.
// +kubebuilder:validation:XValidation:rule="!has(self.capacityReservationId) || !has(self.marketType) || self.marketType != 'Spot'",message="capacityReservationId may not be set when marketType is Spot"
// +kubebuilder:validation:XValidation:rule="!has(self.capacityReservationId) || !has(self.spotMarketOptions)",message="capacityReservationId cannot be set when spotMarketOptions is specified"
// +kubebuilder:validation:XValidation:rule="!has(self.capacityReservationId) || !has(self.capacityReservationResourceGroupARN)",message="capacityReservationId and capacityReservationResourceGroupARN are mutually exclusive"
// +kubebuilder:validation:XValidation:rule="!(has(self.capacityReservationId) || has(self.capacityReservationResourceGroupARN)) || !has(self.marketType) || self.marketType != 'Spot'",message="capacity reservation targets may not be set when marketType is Spot"
// +kubebuilder:validation:XValidation:rule="!(has(self.capacityReservationId) || has(self.capacityReservationResourceGroupARN)) || !has(self.spotMarketOptions)",message="capacity reservation targets cannot be set when spotMarketOptions is specified"
type AWSMachineSpec struct {
// ProviderID is the unique identifier as specified by the cloud provider.
ProviderID *string `json:"providerID,omitempty"`
Expand Down Expand Up @@ -246,11 +247,15 @@ type AWSMachineSpec struct {
// +optional
CapacityReservationID *string `json:"capacityReservationId,omitempty"`

// CapacityReservationResourceGroupARN specifies the ARN of the target Capacity Reservation resource group in which to launch the instance.
// +optional
CapacityReservationResourceGroupARN *string `json:"capacityReservationResourceGroupARN,omitempty"`

// MarketType specifies the type of market for the EC2 instance. Valid values include:
// "OnDemand" (default): The instance runs as a standard OnDemand instance.
// "Spot": The instance runs as a Spot instance. When SpotMarketOptions is provided, the marketType defaults to "Spot".
// "CapacityBlock": The instance utilizes pre-purchased compute capacity (capacity blocks) with AWS Capacity Reservations.
// If this value is selected, CapacityReservationID must be specified to identify the target reservation.
// If this value is selected, either CapacityReservationID or CapacityReservationResourceGroupARN must be specified to identify the target reservation.
// If marketType is not specified and spotMarketOptions is provided, the marketType defaults to "Spot".
// +optional
MarketType MarketType `json:"marketType,omitempty"`
Expand Down
16 changes: 15 additions & 1 deletion api/v1beta2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,15 @@ type Instance struct {
// +optional
CapacityReservationID *string `json:"capacityReservationId,omitempty"`

// CapacityReservationResourceGroupARN specifies the ARN of the target Capacity Reservation resource group in which to launch the instance.
// +optional
CapacityReservationResourceGroupARN *string `json:"capacityReservationResourceGroupARN,omitempty"`

// MarketType specifies the type of market for the EC2 instance. Valid values include:
// "OnDemand" (default): The instance runs as a standard OnDemand instance.
// "Spot": The instance runs as a Spot instance. When SpotMarketOptions is provided, the marketType defaults to "Spot".
// "CapacityBlock": The instance utilizes pre-purchased compute capacity (capacity blocks) with AWS Capacity Reservations.
// If this value is selected, CapacityReservationID must be specified to identify the target reservation.
// If this value is selected, either CapacityReservationID or CapacityReservationResourceGroupARN must be specified to identify the target reservation.
// If marketType is not specified and spotMarketOptions is provided, the marketType defaults to "Spot".
// +optional
MarketType MarketType `json:"marketType,omitempty"`
Expand Down Expand Up @@ -314,6 +318,16 @@ type Instance struct {
CPUOptions CPUOptions `json:"cpuOptions,omitempty,omitzero"`
}

// HasCapacityReservationTarget returns true when either supported capacity reservation target is set.
func HasCapacityReservationTarget(capacityReservationID, capacityReservationResourceGroupARN *string) bool {
return capacityReservationID != nil || capacityReservationResourceGroupARN != nil
}

// HasConflictingCapacityReservationTargets returns true when more than one capacity reservation target is set.
func HasConflictingCapacityReservationTargets(capacityReservationID, capacityReservationResourceGroupARN *string) bool {
return capacityReservationID != nil && capacityReservationResourceGroupARN != nil
}

// CapacityReservationPreference describes the preferred use of capacity reservations
// of an instance
// +kubebuilder:validation:Enum:="";None;CapacityReservationsOnly;Open
Expand Down
10 changes: 10 additions & 0 deletions api/v1beta2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,11 @@ spec:
"None": The instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads
"CapacityReservationsOnly": The instance will only run if matched or targeted to a Capacity Reservation. Note that this is incompatible with a MarketType of `Spot`
type: string
capacityReservationResourceGroupARN:
description: CapacityReservationResourceGroupARN specifies the
ARN of the target Capacity Reservation resource group in which
to launch the instance.
type: string
cpuOptions:
description: |-
CPUOptions defines CPU-related settings for the instance, including the confidential computing policy.
Expand Down Expand Up @@ -1405,7 +1410,7 @@ spec:
"OnDemand" (default): The instance runs as a standard OnDemand instance.
"Spot": The instance runs as a Spot instance. When SpotMarketOptions is provided, the marketType defaults to "Spot".
"CapacityBlock": The instance utilizes pre-purchased compute capacity (capacity blocks) with AWS Capacity Reservations.
If this value is selected, CapacityReservationID must be specified to identify the target reservation.
If this value is selected, either CapacityReservationID or CapacityReservationResourceGroupARN must be specified to identify the target reservation.
If marketType is not specified and spotMarketOptions is provided, the marketType defaults to "Spot".
enum:
- OnDemand
Expand Down Expand Up @@ -3662,6 +3667,11 @@ spec:
"None": The instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads
"CapacityReservationsOnly": The instance will only run if matched or targeted to a Capacity Reservation. Note that this is incompatible with a MarketType of `Spot`
type: string
capacityReservationResourceGroupARN:
description: CapacityReservationResourceGroupARN specifies the
ARN of the target Capacity Reservation resource group in which
to launch the instance.
type: string
cpuOptions:
description: |-
CPUOptions defines CPU-related settings for the instance, including the confidential computing policy.
Expand Down Expand Up @@ -3826,7 +3836,7 @@ spec:
"OnDemand" (default): The instance runs as a standard OnDemand instance.
"Spot": The instance runs as a Spot instance. When SpotMarketOptions is provided, the marketType defaults to "Spot".
"CapacityBlock": The instance utilizes pre-purchased compute capacity (capacity blocks) with AWS Capacity Reservations.
If this value is selected, CapacityReservationID must be specified to identify the target reservation.
If this value is selected, either CapacityReservationID or CapacityReservationResourceGroupARN must be specified to identify the target reservation.
If marketType is not specified and spotMarketOptions is provided, the marketType defaults to "Spot".
enum:
- OnDemand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2262,6 +2262,11 @@ spec:
"None": The instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads
"CapacityReservationsOnly": The instance will only run if matched or targeted to a Capacity Reservation. Note that this is incompatible with a MarketType of `Spot`
type: string
capacityReservationResourceGroupARN:
description: CapacityReservationResourceGroupARN specifies the
ARN of the target Capacity Reservation resource group in which
to launch the instance.
type: string
cpuOptions:
description: |-
CPUOptions defines CPU-related settings for the instance, including the confidential computing policy.
Expand Down Expand Up @@ -2426,7 +2431,7 @@ spec:
"OnDemand" (default): The instance runs as a standard OnDemand instance.
"Spot": The instance runs as a Spot instance. When SpotMarketOptions is provided, the marketType defaults to "Spot".
"CapacityBlock": The instance utilizes pre-purchased compute capacity (capacity blocks) with AWS Capacity Reservations.
If this value is selected, CapacityReservationID must be specified to identify the target reservation.
If this value is selected, either CapacityReservationID or CapacityReservationResourceGroupARN must be specified to identify the target reservation.
If marketType is not specified and spotMarketOptions is provided, the marketType defaults to "Spot".
enum:
- OnDemand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,11 @@ spec:
"None": The instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads
"CapacityReservationsOnly": The instance will only run if matched or targeted to a Capacity Reservation
type: string
capacityReservationResourceGroupARN:
description: CapacityReservationResourceGroupARN specifies the
ARN of the target Capacity Reservation resource group in which
to launch the instance.
type: string
enclaveOptions:
description: EnclaveOptions defines the options for Nitro Enclave
support on the instance.
Expand Down Expand Up @@ -782,7 +787,7 @@ spec:
"OnDemand" (default): The instance runs as a standard OnDemand instance.
"Spot": The instance runs as a Spot instance. When SpotMarketOptions is provided, the marketType defaults to "Spot".
"CapacityBlock": The instance utilizes pre-purchased compute capacity (capacity blocks) with AWS Capacity Reservations.
If this value is selected, CapacityReservationID must be specified to identify the target reservation.
If this value is selected, either CapacityReservationID or CapacityReservationResourceGroupARN must be specified to identify the target reservation.
If marketType is not specified and spotMarketOptions is provided, the marketType defaults to "Spot".
enum:
- OnDemand
Expand Down Expand Up @@ -921,6 +926,18 @@ spec:
format: int64
type: integer
type: object
x-kubernetes-validations:
- message: capacityReservationId and capacityReservationResourceGroupARN
are mutually exclusive
rule: '!has(self.capacityReservationId) || !has(self.capacityReservationResourceGroupARN)'
- message: capacity reservation targets may not be set when marketType
is Spot
rule: '!(has(self.capacityReservationId) || has(self.capacityReservationResourceGroupARN))
|| !has(self.marketType) || self.marketType != ''Spot'''
- message: capacity reservation targets cannot be set when spotMarketOptions
is specified
rule: '!(has(self.capacityReservationId) || has(self.capacityReservationResourceGroupARN))
|| !has(self.spotMarketOptions)'
capacityRebalance:
description: Enable or disable the capacity rebalance autoscaling
group feature
Expand Down
22 changes: 16 additions & 6 deletions config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,11 @@ spec:
"None": The instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads
"CapacityReservationsOnly": The instance will only run if matched or targeted to a Capacity Reservation. Note that this is incompatible with a MarketType of `Spot`
type: string
capacityReservationResourceGroupARN:
description: CapacityReservationResourceGroupARN specifies the ARN
of the target Capacity Reservation resource group in which to launch
the instance.
type: string
cloudInit:
description: |-
CloudInit defines options related to the bootstrapping systems where
Expand Down Expand Up @@ -1015,7 +1020,7 @@ spec:
"OnDemand" (default): The instance runs as a standard OnDemand instance.
"Spot": The instance runs as a Spot instance. When SpotMarketOptions is provided, the marketType defaults to "Spot".
"CapacityBlock": The instance utilizes pre-purchased compute capacity (capacity blocks) with AWS Capacity Reservations.
If this value is selected, CapacityReservationID must be specified to identify the target reservation.
If this value is selected, either CapacityReservationID or CapacityReservationResourceGroupARN must be specified to identify the target reservation.
If marketType is not specified and spotMarketOptions is provided, the marketType defaults to "Spot".
enum:
- OnDemand
Expand Down Expand Up @@ -1240,12 +1245,17 @@ spec:
- instanceType
type: object
x-kubernetes-validations:
- message: capacityReservationId may not be set when marketType is Spot
rule: '!has(self.capacityReservationId) || !has(self.marketType) ||
self.marketType != ''Spot'''
- message: capacityReservationId cannot be set when spotMarketOptions
- message: capacityReservationId and capacityReservationResourceGroupARN
are mutually exclusive
rule: '!has(self.capacityReservationId) || !has(self.capacityReservationResourceGroupARN)'
- message: capacity reservation targets may not be set when marketType
is Spot
rule: '!(has(self.capacityReservationId) || has(self.capacityReservationResourceGroupARN))
|| !has(self.marketType) || self.marketType != ''Spot'''
- message: capacity reservation targets cannot be set when spotMarketOptions
is specified
rule: '!has(self.capacityReservationId) || !has(self.spotMarketOptions)'
rule: '!(has(self.capacityReservationId) || has(self.capacityReservationResourceGroupARN))
|| !has(self.spotMarketOptions)'
status:
description: AWSMachineStatus defines the observed state of AWSMachine.
properties:
Expand Down
Loading
Loading