Skip to content

Commit f298734

Browse files
committed
Added support for legacy AWS dedicated hosts
1 parent 6ab113c commit f298734

5 files changed

Lines changed: 222 additions & 22 deletions

File tree

machine/v1beta1/types_awsprovider.go

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,13 @@ const (
430430

431431
// HostPlacement is the type that will be used to configure the placement of AWS instances.
432432
// +kubebuilder:validation:XValidation:rule="has(self.affinity) && self.affinity == 'DedicatedHost' ? has(self.dedicatedHost) : true",message="dedicatedHost is required when affinity is DedicatedHost, and optional otherwise"
433+
// +kubebuilder:validation:XValidation:rule="has(self.affinity) && has(self.dynamicHost) ? self.affinity == 'DynamicHost' : true",message="dynamicHost is only allowed when affinity is DynamicHost, and forbidden otherwise"
433434
// +union
434435
type HostPlacement struct {
435436
// affinity specifies the affinity setting for the instance.
436437
// Allowed values are AnyAvailable and DedicatedHost.
437438
// When Affinity is set to DedicatedHost, an instance started onto a specific host always restarts on the same host if stopped. In this scenario, the `dedicatedHost` field must be set.
439+
// When Affinity is set to DynamicHost, a dedicated host will be allocated and assigned to the instance and the instance will always restart on this host if stopped. In this scenario, the `dynamicHost` field may be set to provide additional settings.
438440
// When Affinity is set to AnyAvailable, and you stop and restart the instance, it can be restarted on any available host.
439441
// When Affinity is set to AnyAvailable and the `dedicatedHost` field is defined, it runs on specified Dedicated Host, but may move if stopped.
440442
// +required
@@ -460,15 +462,47 @@ const (
460462
HostAffinityDedicatedHost HostAffinity = "DedicatedHost"
461463
)
462464

465+
// AllocationStrategy selects how a dedicated host is provided to the system for assigning to the instance.
466+
// +kubebuilder:validation:Enum:=Provided;Dynamic
467+
type AllocationStrategy string
468+
469+
const (
470+
AllocationStrategyUserProvided AllocationStrategy = "Provided"
471+
AllocationStrategyDynamic AllocationStrategy = "Dynamic"
472+
)
473+
463474
// DedicatedHost represents the configuration for the usage of dedicated host.
475+
// +kubebuilder:validation:XValidation:rule="self.allocationStrategy == 'Provided' ? has(self.id) : true",message="id is required when allocationStrategy is Provided, and forbidden otherwise"
476+
// +kubebuilder:validation:XValidation:rule="has(self.id) ? self.allocationStrategy == 'Provided' : true",message="id is required when allocationStrategy is Provided, and forbidden otherwise"
477+
// +kubebuilder:validation:XValidation:rule="has(self.dynamicHostAllocation) ? self.allocationStrategy == 'Dynamic' : true",message="dynamicHostAllocation is only allowed when allocationStrategy is Dynamic"
464478
type DedicatedHost struct {
479+
// allocationStrategy specifies if the dedicated host will be provided by the admin through the id field or if the host
480+
// will be dynamically allocated.
481+
// +required
482+
AllocationStrategy AllocationStrategy `json:"allocationStrategy"`
483+
465484
// id identifies the AWS Dedicated Host on which the instance must run.
466485
// The value must start with "h-" followed by either 8 or 17 lowercase hexadecimal characters (0-9 and a-f).
467486
// The use of 8 lowercase hexadecimal characters is for older legacy hosts that may not have been migrated to newer format.
468487
// Must be either 10 or 19 characters in length.
469488
// +kubebuilder:validation:XValidation:rule="self.matches('^h-([0-9a-f]{8}|[0-9a-f]{17})$')",message="hostID must start with 'h-' followed by either 8 or 17 lowercase hexadecimal characters (0-9 and a-f)"
470489
// +kubebuilder:validation:MinLength=10
471490
// +kubebuilder:validation:MaxLength=19
472-
// +required
491+
// +optional
492+
// +unionMember
473493
ID string `json:"id,omitempty"`
494+
495+
// dynamicHost enables automatic allocation of a single dedicated host.
496+
// This field is mutually exclusive with dedicatedHost and always allocates exactly one host.
497+
// +optional
498+
// +unionMember
499+
DynamicHostAllocation *DynamicHostAllocationSpec `json:"dynamicHostAllocation,omitempty"`
500+
}
501+
502+
// DynamicHostAllocationSpec defines the configuration for dynamic dedicated host allocation.
503+
// This specification always allocates exactly one dedicated host per machine.
504+
type DynamicHostAllocationSpec struct {
505+
// tags to apply to the allocated dedicated host.
506+
// +optional
507+
Tags map[string]string `json:"tags,omitempty"`
474508
}

machine/v1beta1/zz_generated.deepcopy.go

Lines changed: 29 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

machine/v1beta1/zz_generated.swagger_doc_generated.go

Lines changed: 14 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openapi/generated_openapi/zz_generated.openapi.go

Lines changed: 48 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)