@@ -41,6 +41,19 @@ const (
4141 DefaultMachinePoolIgnitionStorageType = IgnitionStorageTypeOptionUnencryptedUserData
4242)
4343
44+ // DynamicHostReleaseStrategy defines the strategy for releasing a dynamically allocated dedicated host.
45+ // It determines when the dedicated host associated with an AWSMachine should be released, such as
46+ // automatically upon machine deletion or only when manually triggered.
47+ type DynamicHostReleaseStrategy string
48+
49+ const (
50+ // DedicatedHostReleaseStrategyOnMachineDeletion means the dedicated host will be released when the machine is deleted.
51+ DedicatedHostReleaseStrategyOnMachineDeletion = DynamicHostReleaseStrategy ("on-machine-deletion" )
52+
53+ // DedicatedHostReleaseStrategyManual means the dedicated host will be released manually by the user.
54+ DedicatedHostReleaseStrategyManual = DynamicHostReleaseStrategy ("manual" )
55+ )
56+
4457// SecretBackend defines variants for backend secret storage.
4558type SecretBackend string
4659
@@ -235,17 +248,25 @@ type AWSMachineSpec struct {
235248 MarketType MarketType `json:"marketType,omitempty"`
236249
237250 // HostID specifies the Dedicated Host on which the instance must be started.
251+ // This field is mutually exclusive with DynamicHostAllocation.
252+ // +kubebuilder:validation:Pattern=`^h-[0-9a-f]{17}$`
238253 // +optional
239254 HostID * string `json:"hostID,omitempty"`
240255
241256 // HostAffinity specifies the dedicated host affinity setting for the instance.
242- // When hostAffinity is set to host, an instance started onto a specific host always restarts on the same host if stopped.
243- // When hostAffinity is set to default, and you stop and restart the instance, it can be restarted on any available host.
257+ // When HostAffinity is set to host, an instance started onto a specific host always restarts on the same host if stopped.
258+ // When HostAffinity is set to default, and you stop and restart the instance, it can be restarted on any available host.
244259 // When HostAffinity is defined, HostID is required.
245260 // +optional
246261 // +kubebuilder:validation:Enum:=default;host
262+ // +kubebuilder:default=default
247263 HostAffinity * string `json:"hostAffinity,omitempty"`
248264
265+ // DynamicHostAllocation enables automatic allocation of a single dedicated host.
266+ // This field is mutually exclusive with HostID and always allocates exactly one host.
267+ // +optional
268+ DynamicHostAllocation * DynamicHostAllocationSpec `json:"dynamicHostAllocation,omitempty"`
269+
249270 // CapacityReservationPreference specifies the preference for use of Capacity Reservations by the instance. Valid values include:
250271 // "Open": The instance may make use of open Capacity Reservations that match its AZ and InstanceType
251272 // "None": The instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads
@@ -255,6 +276,21 @@ type AWSMachineSpec struct {
255276 CapacityReservationPreference CapacityReservationPreference `json:"capacityReservationPreference,omitempty"`
256277}
257278
279+ // DynamicHostAllocationSpec defines the configuration for dynamic dedicated host allocation.
280+ // This specification always allocates exactly one dedicated host per machine.
281+ type DynamicHostAllocationSpec struct {
282+ // AutoRelease determines whether to automatically release the dedicated host
283+ // when the machine is deleted.
284+ // +kubebuilder:default=on-machine-deletion
285+ // +kubebuilder:validation:Enum:=on-machine-deletion;manual
286+ // +optional
287+ Release DynamicHostReleaseStrategy `json:"release,omitempty"`
288+
289+ // Tags to apply to the allocated dedicated host.
290+ // +optional
291+ Tags map [string ]string `json:"tags,omitempty"`
292+ }
293+
258294// CloudInit defines options related to the bootstrapping systems where
259295// CloudInit is used.
260296type CloudInit struct {
@@ -432,6 +468,26 @@ type AWSMachineStatus struct {
432468 // Conditions defines current service state of the AWSMachine.
433469 // +optional
434470 Conditions clusterv1.Conditions `json:"conditions,omitempty"`
471+
472+ // AllocatedHostID tracks the dynamically allocated dedicated host ID.
473+ // This field is populated when DynamicHostAllocation is used.
474+ // +optional
475+ AllocatedHostID * string `json:"allocatedHostID,omitempty"`
476+
477+ // HostReleaseAttempts tracks the number of attempts to release the dedicated host.
478+ // This field is used for implementing retry logic when host release fails.
479+ // +optional
480+ HostReleaseAttempts * int32 `json:"hostReleaseAttempts,omitempty"`
481+
482+ // LastHostReleaseAttempt tracks the timestamp of the last attempt to release the dedicated host.
483+ // This field is used for implementing retry logic with backoff.
484+ // +optional
485+ LastHostReleaseAttempt * metav1.Time `json:"lastHostReleaseAttempt,omitempty"`
486+
487+ // HostReleaseFailedReason tracks the reason for the last host release failure.
488+ // This field is used for debugging and implementing retry logic.
489+ // +optional
490+ HostReleaseFailedReason * string `json:"hostReleaseFailedReason,omitempty"`
435491}
436492
437493// +kubebuilder:object:root=true
0 commit comments