-
Notifications
You must be signed in to change notification settings - Fork 628
✨ Allocate dedicated host when a dedicated host doesn't exist #5631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
|
@@ -218,6 +218,10 @@ type AWSMachineSpec struct { | |
PlacementGroupPartition int64 `json:"placementGroupPartition,omitempty"` | ||
|
||
// Tenancy indicates if instance should run on shared or single-tenant hardware. | ||
// When Tenancy=host, AWS will attempt to find a suitable host from: | ||
// - Preexisting allocated hosts that have auto-placement enabled | ||
// - A specific host ID, if configured | ||
// - Allocating a new dedicated host if DynamicHostAllocation is configured | ||
// +optional | ||
// +kubebuilder:validation:Enum:=default;dedicated;host | ||
Tenancy string `json:"tenancy,omitempty"` | ||
|
@@ -240,17 +244,28 @@ type AWSMachineSpec struct { | |
MarketType MarketType `json:"marketType,omitempty"` | ||
|
||
// HostID specifies the Dedicated Host on which the instance must be started. | ||
// This field is mutually exclusive with DynamicHostAllocation. | ||
// +kubebuilder:validation:Pattern=`^h-[0-9a-f]{17}$` | ||
// +kubebuilder:validation:MaxLength=19 | ||
// +optional | ||
HostID *string `json:"hostID,omitempty"` | ||
|
||
// HostAffinity specifies the dedicated host affinity setting for the instance. | ||
// When hostAffinity is set to host, an instance started onto a specific host always restarts on the same host if stopped. | ||
// When hostAffinity is set to default, and you stop and restart the instance, it can be restarted on any available host. | ||
// When HostAffinity is set to host, an instance started onto a specific host always restarts on the same host if stopped. | ||
// When HostAffinity is set to default, and you stop and restart the instance, it can be restarted on any available host. | ||
// When HostAffinity is defined, HostID is required. | ||
// +optional | ||
// +kubebuilder:validation:Enum:=default;host | ||
// +kubebuilder:default=host | ||
HostAffinity *string `json:"hostAffinity,omitempty"` | ||
|
||
// DynamicHostAllocation enables automatic allocation of a single dedicated host. | ||
// This field is mutually exclusive with HostID and always allocates exactly one host. | ||
// Cost effectiveness of allocating a single instance on a dedicated host may vary | ||
// depending on the instance type and the region. | ||
// +optional | ||
DynamicHostAllocation *DynamicHostAllocationSpec `json:"dynamicHostAllocation,omitempty"` | ||
|
||
// CapacityReservationPreference specifies the preference for use of Capacity Reservations by the instance. Valid values include: | ||
// "Open": The instance may make use of open Capacity Reservations that match its AZ and InstanceType | ||
// "None": The instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads | ||
|
@@ -260,6 +275,14 @@ type AWSMachineSpec struct { | |
CapacityReservationPreference CapacityReservationPreference `json:"capacityReservationPreference,omitempty"` | ||
} | ||
|
||
// DynamicHostAllocationSpec defines the configuration for dynamic dedicated host allocation. | ||
// This specification always allocates exactly one dedicated host per machine. | ||
type DynamicHostAllocationSpec struct { | ||
// Tags to apply to the allocated dedicated host. | ||
// +optional | ||
Tags map[string]string `json:"tags,omitempty"` | ||
} | ||
Comment on lines
+281
to
+284
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use the same tags that are present on Machine under There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could for sure. will make that change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @punkwalker Ive made the change to include tags specified in spec.additionalTags. I looked at including the default tags as well but it seemed odd to apply some of them to the dedicated host. For example, the role tag that would be attached to the machine is node and that was be propagated to the dedicate host. I assumed default tags meant those that would be applied to the machine but I may have misunderstood. What did you mean by "default tags"? |
||
|
||
// CloudInit defines options related to the bootstrapping systems where | ||
// CloudInit is used. | ||
type CloudInit struct { | ||
|
@@ -438,6 +461,37 @@ type AWSMachineStatus struct { | |
// Conditions defines current service state of the AWSMachine. | ||
// +optional | ||
Conditions clusterv1.Conditions `json:"conditions,omitempty"` | ||
|
||
// DedicatedHost tracks the dynamically allocated dedicated host. | ||
// This field is populated when DynamicHostAllocation is used. | ||
// +optional | ||
DedicatedHost *DedicatedHostStatus `json:"dedicatedHost,omitempty"` | ||
|
||
// HostReleaseAttempts tracks the number of attempts to release the dedicated host. | ||
// +optional | ||
HostReleaseAttempts *int32 `json:"hostReleaseAttempts,omitempty"` | ||
|
||
// LastHostReleaseAttempt tracks the timestamp of the last attempt to release the dedicated host. | ||
// +optional | ||
LastHostReleaseAttempt *metav1.Time `json:"lastHostReleaseAttempt,omitempty"` | ||
|
||
// HostReleaseFailedReason tracks the reason for the last host release failure. | ||
// +optional | ||
HostReleaseFailedReason *string `json:"hostReleaseFailedReason,omitempty"` | ||
} | ||
|
||
// DedicatedHostStatus defines the observed state of a dynamically allocated dedicated host | ||
// associated with an AWSMachine. This struct is used to track the ID of the dedicated host | ||
// and any failure messages encountered during host release operations. | ||
type DedicatedHostStatus struct { | ||
// ID tracks the dynamically allocated dedicated host ID. | ||
// This field is populated when DynamicHostAllocation is used. | ||
// +optional | ||
ID *string `json:"id,omitempty"` | ||
|
||
// ReleaseFailureMessage tracks the last failure message for the release host attempt. | ||
// +optional | ||
ReleaseFailureMessage *string `json:"releaseFailureMessage,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe include some more context for consumers here e.g:
"depending on the instance type used, the host allocation for that single instance might be less or more cost effective. This is usually a good fit for metal instance types..."
@punkwalker is it fair to say that the .metal size instance types would always use all the host allocation sockets/cpus for that same type? as in the example here https://aws.amazon.com/blogs/compute/understanding-the-lifecycle-of-amazon-ec2-dedicated-hosts
it would be also nice to document better the .Tenancy field, e.g.
"when .tenancy=host is set, you can either let aws find a suitable host for you from preexisting allocations that have auto-placement enabled, choose an specific .hostID, or use dynamicHostAllocation to create a dedicated host allocation for the instance.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that this is mostly true for all instance families but there can be some exceptions as well. However, as we are going with 1:1 mapping, I don't think so we need to consider this as of now.
Similarly for this, if we do 1:1 mapping then we should not use auto-placement as it will be redundant when we place only single instance on the host.