Skip to content

Commit e9dc543

Browse files
rvanderp3jimzim
andcommitted
WIP: Allocate dedicated host
Co-authored-by: Jim Zimmerman <[email protected]>
1 parent 8ab8731 commit e9dc543

20 files changed

+1235
-9
lines changed

api/v1beta1/conversion.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,8 @@ func Convert_v1beta2_S3Bucket_To_v1beta1_S3Bucket(in *v1beta2.S3Bucket, out *S3B
103103
func Convert_v1beta2_Ignition_To_v1beta1_Ignition(in *v1beta2.Ignition, out *Ignition, s conversion.Scope) error {
104104
return autoConvert_v1beta2_Ignition_To_v1beta1_Ignition(in, out, s)
105105
}
106+
107+
func Convert_v1beta2_AWSMachineStatus_To_v1beta1_AWSMachineStatus(in *v1beta2.AWSMachineStatus, out *AWSMachineStatus, s conversion.Scope) error {
108+
// Note: AllocatedHostID is not present in v1beta1, so it will be dropped during conversion
109+
return autoConvert_v1beta2_AWSMachineStatus_To_v1beta1_AWSMachineStatus(in, out, s)
110+
}

api/v1beta1/zz_generated.conversion.go

Lines changed: 3 additions & 5 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: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ type AWSMachineSpec struct {
246246
// +kubebuilder:validation:Enum:=default;host
247247
HostAffinity *string `json:"hostAffinity,omitempty"`
248248

249+
// DynamicHostAllocation enables automatic allocation of dedicated hosts.
250+
// This field is mutually exclusive with HostID.
251+
// +optional
252+
DynamicHostAllocation *DynamicHostAllocationSpec `json:"dynamicHostAllocation,omitempty"`
253+
249254
// CapacityReservationPreference specifies the preference for use of Capacity Reservations by the instance. Valid values include:
250255
// "Open": The instance may make use of open Capacity Reservations that match its AZ and InstanceType
251256
// "None": The instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads
@@ -255,6 +260,40 @@ type AWSMachineSpec struct {
255260
CapacityReservationPreference CapacityReservationPreference `json:"capacityReservationPreference,omitempty"`
256261
}
257262

263+
// DynamicHostAllocationSpec defines the configuration for dynamic dedicated host allocation.
264+
type DynamicHostAllocationSpec struct {
265+
// InstanceFamily specifies the EC2 instance family (e.g., "m5", "c5", "r5").
266+
// +kubebuilder:validation:Required
267+
InstanceFamily string `json:"instanceFamily"`
268+
269+
// AvailabilityZone specifies the target availability zone for allocation.
270+
// If not specified, uses the same AZ as the instance.
271+
// +optional
272+
AvailabilityZone *string `json:"availabilityZone,omitempty"`
273+
274+
// InstanceType specifies the specific instance type for the dedicated host.
275+
// If not specified, derives from InstanceFamily.
276+
// +optional
277+
InstanceType *string `json:"instanceType,omitempty"`
278+
279+
// Quantity specifies the number of dedicated hosts to allocate.
280+
// +kubebuilder:validation:Minimum=1
281+
// +kubebuilder:validation:Maximum=10
282+
// +kubebuilder:default=1
283+
// +optional
284+
Quantity *int32 `json:"quantity,omitempty"`
285+
286+
// AutoRelease determines whether to automatically release the dedicated host
287+
// when the machine is deleted.
288+
// +kubebuilder:default=true
289+
// +optional
290+
AutoRelease *bool `json:"autoRelease,omitempty"`
291+
292+
// Tags to apply to the allocated dedicated host.
293+
// +optional
294+
Tags map[string]string `json:"tags,omitempty"`
295+
}
296+
258297
// CloudInit defines options related to the bootstrapping systems where
259298
// CloudInit is used.
260299
type CloudInit struct {
@@ -432,6 +471,11 @@ type AWSMachineStatus struct {
432471
// Conditions defines current service state of the AWSMachine.
433472
// +optional
434473
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
474+
475+
// AllocatedHostID tracks the dynamically allocated dedicated host ID.
476+
// This field is populated when DynamicHostAllocation is used.
477+
// +optional
478+
AllocatedHostID *string `json:"allocatedHostID,omitempty"`
435479
}
436480

437481
// +kubebuilder:object:root=true

api/v1beta2/types.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ type Instance struct {
286286
// +optional
287287
HostID *string `json:"hostID,omitempty"`
288288

289+
// DynamicHostAllocation enables automatic allocation of dedicated hosts.
290+
// This field is mutually exclusive with HostID.
291+
// +optional
292+
DynamicHostAllocation *DynamicHostAllocationSpec `json:"dynamicHostAllocation,omitempty"`
293+
289294
// CapacityReservationPreference specifies the preference for use of Capacity Reservations by the instance. Valid values include:
290295
// "Open": The instance may make use of open Capacity Reservations that match its AZ and InstanceType
291296
// "None": The instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads
@@ -311,6 +316,33 @@ const (
311316
CapacityReservationPreferenceOpen CapacityReservationPreference = "Open"
312317
)
313318

319+
// DedicatedHostInfo contains information about a dedicated host.
320+
type DedicatedHostInfo struct {
321+
// HostID is the ID of the dedicated host.
322+
HostID string `json:"hostID"`
323+
324+
// InstanceFamily is the instance family supported by the host.
325+
InstanceFamily string `json:"instanceFamily"`
326+
327+
// InstanceType is the instance type supported by the host.
328+
InstanceType string `json:"instanceType"`
329+
330+
// AvailabilityZone is the AZ where the host is located.
331+
AvailabilityZone string `json:"availabilityZone"`
332+
333+
// State is the current state of the dedicated host.
334+
State string `json:"state"`
335+
336+
// TotalCapacity is the total number of instances that can be launched on the host.
337+
TotalCapacity int32 `json:"totalCapacity"`
338+
339+
// AvailableCapacity is the number of instances that can still be launched on the host.
340+
AvailableCapacity int32 `json:"availableCapacity"`
341+
342+
// Tags associated with the dedicated host.
343+
Tags map[string]string `json:"tags,omitempty"`
344+
}
345+
314346
// MarketType describes the market type of an Instance
315347
// +kubebuilder:validation:Enum:=OnDemand;Spot;CapacityBlock
316348
type MarketType string

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 79 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: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,47 @@ spec:
12321232
"None": The instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads
12331233
"CapacityReservationsOnly": The instance will only run if matched or targeted to a Capacity Reservation
12341234
type: string
1235+
dynamicHostAllocation:
1236+
description: |-
1237+
DynamicHostAllocation enables automatic allocation of dedicated hosts.
1238+
This field is mutually exclusive with HostID.
1239+
properties:
1240+
autoRelease:
1241+
default: true
1242+
description: |-
1243+
AutoRelease determines whether to automatically release the dedicated host
1244+
when the machine is deleted.
1245+
type: boolean
1246+
availabilityZone:
1247+
description: |-
1248+
AvailabilityZone specifies the target availability zone for allocation.
1249+
If not specified, uses the same AZ as the instance.
1250+
type: string
1251+
instanceFamily:
1252+
description: InstanceFamily specifies the EC2 instance family
1253+
(e.g., "m5", "c5", "r5").
1254+
type: string
1255+
instanceType:
1256+
description: |-
1257+
InstanceType specifies the specific instance type for the dedicated host.
1258+
If not specified, derives from InstanceFamily.
1259+
type: string
1260+
quantity:
1261+
default: 1
1262+
description: Quantity specifies the number of dedicated hosts
1263+
to allocate.
1264+
format: int32
1265+
maximum: 10
1266+
minimum: 1
1267+
type: integer
1268+
tags:
1269+
additionalProperties:
1270+
type: string
1271+
description: Tags to apply to the allocated dedicated host.
1272+
type: object
1273+
required:
1274+
- instanceFamily
1275+
type: object
12351276
ebsOptimized:
12361277
description: Indicates whether the instance is optimized for Amazon
12371278
EBS I/O.
@@ -3446,6 +3487,47 @@ spec:
34463487
"None": The instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads
34473488
"CapacityReservationsOnly": The instance will only run if matched or targeted to a Capacity Reservation
34483489
type: string
3490+
dynamicHostAllocation:
3491+
description: |-
3492+
DynamicHostAllocation enables automatic allocation of dedicated hosts.
3493+
This field is mutually exclusive with HostID.
3494+
properties:
3495+
autoRelease:
3496+
default: true
3497+
description: |-
3498+
AutoRelease determines whether to automatically release the dedicated host
3499+
when the machine is deleted.
3500+
type: boolean
3501+
availabilityZone:
3502+
description: |-
3503+
AvailabilityZone specifies the target availability zone for allocation.
3504+
If not specified, uses the same AZ as the instance.
3505+
type: string
3506+
instanceFamily:
3507+
description: InstanceFamily specifies the EC2 instance family
3508+
(e.g., "m5", "c5", "r5").
3509+
type: string
3510+
instanceType:
3511+
description: |-
3512+
InstanceType specifies the specific instance type for the dedicated host.
3513+
If not specified, derives from InstanceFamily.
3514+
type: string
3515+
quantity:
3516+
default: 1
3517+
description: Quantity specifies the number of dedicated hosts
3518+
to allocate.
3519+
format: int32
3520+
maximum: 10
3521+
minimum: 1
3522+
type: integer
3523+
tags:
3524+
additionalProperties:
3525+
type: string
3526+
description: Tags to apply to the allocated dedicated host.
3527+
type: object
3528+
required:
3529+
- instanceFamily
3530+
type: object
34493531
ebsOptimized:
34503532
description: Indicates whether the instance is optimized for Amazon
34513533
EBS I/O.

0 commit comments

Comments
 (0)