Skip to content

Commit 32e3b64

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

5 files changed

Lines changed: 225 additions & 19 deletions

File tree

machine/v1beta1/types_awsprovider.go

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ 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.
@@ -460,15 +461,56 @@ const (
460461
HostAffinityDedicatedHost HostAffinity = "DedicatedHost"
461462
)
462463

464+
// AllocationStrategy selects how a dedicated host is provided to the system for assigning to the instance.
465+
// +kubebuilder:validation:Enum:=Provided;Dynamic
466+
type AllocationStrategy string
467+
468+
const (
469+
// AllocationStrategyUserProvided specifies system is to assign a provided dedicated host to instances.
470+
AllocationStrategyUserProvided AllocationStrategy = "Provided"
471+
472+
// AllocationStrategyDynamic specifies system to dynamically allocate a dedicated host to use for assignment to instances.
473+
AllocationStrategyDynamic AllocationStrategy = "Dynamic"
474+
)
475+
463476
// DedicatedHost represents the configuration for the usage of dedicated host.
477+
// +kubebuilder:validation:XValidation:rule="self.allocationStrategy == 'Provided' ? has(self.id) : true",message="id is required when allocationStrategy is Provided, and forbidden otherwise"
478+
// +kubebuilder:validation:XValidation:rule="has(self.id) ? self.allocationStrategy == 'Provided' : true",message="id is only allowed when allocationStrategy is Provided"
479+
// +kubebuilder:validation:XValidation:rule="has(self.dynamicHostAllocation) ? self.allocationStrategy == 'Dynamic' : true",message="dynamicHostAllocation is only allowed when allocationStrategy is Dynamic"
464480
type DedicatedHost struct {
481+
// allocationStrategy specifies if the dedicated host will be provided by the admin through the id field or if the host will be dynamically allocated.
482+
// Valid values are Provided and Dynamic.
483+
// The current default value is "Provided".
484+
// When AllocationStrategy is set to Provided, an ID of the dedicated host to assign must be provided.
485+
// When AllocationStrategy is set to Dynamic, a dedicated host will be allocated and used to assign instances.
486+
// When AllocationStrategy is set to Dynamic, and DynamicHostAllocation is provided, a dedicated host will be allocated and the tags in DynamicHostAllocation will be assigned to that host.
487+
// +required
488+
// +unionDiscriminator
489+
// +kubebuilder:default=Provided
490+
AllocationStrategy AllocationStrategy `json:"allocationStrategy,omitempty"`
491+
465492
// id identifies the AWS Dedicated Host on which the instance must run.
466493
// The value must start with "h-" followed by either 8 or 17 lowercase hexadecimal characters (0-9 and a-f).
467494
// The use of 8 lowercase hexadecimal characters is for older legacy hosts that may not have been migrated to newer format.
468495
// Must be either 10 or 19 characters in length.
469496
// +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)"
470497
// +kubebuilder:validation:MinLength=10
471498
// +kubebuilder:validation:MaxLength=19
472-
// +required
499+
// +optional
500+
// +unionMember
473501
ID string `json:"id,omitempty"`
502+
503+
// dynamicHostAllocation specifies tags to apply to a dynamically allocated dedicated host.
504+
// This field is mutually exclusive with id and always allocates exactly one host.
505+
// +optional
506+
// +unionMember
507+
DynamicHostAllocation *DynamicHostAllocationSpec `json:"dynamicHostAllocation,omitempty"`
508+
}
509+
510+
// DynamicHostAllocationSpec defines the configuration for dynamic dedicated host allocation.
511+
// This specification always allocates exactly one dedicated host per machine.
512+
type DynamicHostAllocationSpec struct {
513+
// tags to apply to the allocated dedicated host.
514+
// +optional
515+
Tags map[string]string `json:"tags,omitempty"`
474516
}

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: 13 additions & 2 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: 46 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)