Skip to content

Commit a0eaff3

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

5 files changed

Lines changed: 224 additions & 19 deletions

File tree

machine/v1beta1/types_awsprovider.go

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,15 +460,56 @@ const (
460460
HostAffinityDedicatedHost HostAffinity = "DedicatedHost"
461461
)
462462

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

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)