Skip to content

wip: SPLAT-2172: perform IPI installation on AWS dedicated hosts #9795

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions data/data/install.openshift.io_installconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,24 @@ spec:
AMIID is the AMI that should be used to boot the ec2 instance.
If set, the AMI should belong to the same region as the cluster.
type: string
hostAffinity:
description: |-
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 defined, HostID is required.
enum:
- default
- host
type: string
hostIDs:
description: |-
HostIDs specifies a slice of dedicated hosts on which instances should be started.
presently, only a single dedicated host can be specified per pool.
items:
type: string
maxItems: 1
type: array
iamProfile:
description: |-
IAMProfile is the name of the IAM instance profile to use for the machine.
Expand Down Expand Up @@ -1452,6 +1470,24 @@ spec:
AMIID is the AMI that should be used to boot the ec2 instance.
If set, the AMI should belong to the same region as the cluster.
type: string
hostAffinity:
description: |-
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 defined, HostID is required.
enum:
- default
- host
type: string
hostIDs:
description: |-
HostIDs specifies a slice of dedicated hosts on which instances should be started.
presently, only a single dedicated host can be specified per pool.
items:
type: string
maxItems: 1
type: array
iamProfile:
description: |-
IAMProfile is the name of the IAM instance profile to use for the machine.
Expand Down Expand Up @@ -2711,6 +2747,24 @@ spec:
AMIID is the AMI that should be used to boot the ec2 instance.
If set, the AMI should belong to the same region as the cluster.
type: string
hostAffinity:
description: |-
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 defined, HostID is required.
enum:
- default
- host
type: string
hostIDs:
description: |-
HostIDs specifies a slice of dedicated hosts on which instances should be started.
presently, only a single dedicated host can be specified per pool.
items:
type: string
maxItems: 1
type: array
iamProfile:
description: |-
IAMProfile is the name of the IAM instance profile to use for the machine.
Expand Down Expand Up @@ -4193,6 +4247,24 @@ spec:
AMIID is the AMI that should be used to boot the ec2 instance.
If set, the AMI should belong to the same region as the cluster.
type: string
hostAffinity:
description: |-
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 defined, HostID is required.
enum:
- default
- host
type: string
hostIDs:
description: |-
HostIDs specifies a slice of dedicated hosts on which instances should be started.
presently, only a single dedicated host can be specified per pool.
items:
type: string
maxItems: 1
type: array
iamProfile:
description: |-
IAMProfile is the name of the IAM instance profile to use for the machine.
Expand Down
7 changes: 7 additions & 0 deletions pkg/asset/machines/aws/awsmachines.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type MachineInput struct {
PublicIP bool
PublicIpv4Pool string
Ignition *capa.Ignition
HostAffinity string
HostIDs []string
}

// GenerateMachines returns manifests and runtime objects to provision the control plane (including bootstrap, if applicable) nodes using CAPI.
Expand Down Expand Up @@ -86,6 +88,9 @@ func GenerateMachines(clusterID string, in *MachineInput) ([]*asset.RuntimeFile,
}
}

if len(in.hostIDs) > 1 {
// warn
}
awsMachine := &capa.AWSMachine{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-%s-%d", clusterID, in.Pool.Name, idx),
Expand All @@ -103,6 +108,8 @@ func GenerateMachines(clusterID string, in *MachineInput) ([]*asset.RuntimeFile,
Subnet: subnet,
PublicIP: ptr.To(in.PublicIP),
AdditionalTags: in.Tags,
HostID: ptr.To(in.HostIDs[0]),
HostAffinity: ptr.To(in.HostAffinity),
RootVolume: &capa.Volume{
Size: int64(mpool.EC2RootVolume.Size),
Type: capa.VolumeType(mpool.EC2RootVolume.Type),
Expand Down
21 changes: 21 additions & 0 deletions pkg/types/aws/machinepool.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package aws

const (
// HostAffinityDefault if an instance is stopped and restarted, it can be restarted on any available host.
HostAffinityDefault = "default"
// HostAffinityHost an instance started onto a specific host always restarts on the same host if stopped.
HostAffinityHost = "host"
)

// MachinePool stores the configuration for a machine pool installed
// on AWS.
type MachinePool struct {
Expand Down Expand Up @@ -48,6 +55,20 @@ type MachinePool struct {
// +kubebuilder:validation:MaxItems=10
// +optional
AdditionalSecurityGroupIDs []string `json:"additionalSecurityGroupIDs,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 defined, HostID is required.
// +optional
// +kubebuilder:validation:Enum:=default;host
HostAffinity string `json:"hostAffinity,omitempty"`

// HostIDs specifies a slice of dedicated hosts on which instances should be started.
// presently, only a single dedicated host can be specified per pool.
// +kubebuilder:validation:MaxItems=1
// +optional
HostIDs []string `json:"hostIDs,omitempty"`
}

// Set sets the values from `required` to `a`.
Expand Down
12 changes: 12 additions & 0 deletions pkg/types/aws/validation/machinepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ func ValidateMachinePool(platform *aws.Platform, p *aws.MachinePool, fldPath *fi

allErrs = append(allErrs, validateSecurityGroups(platform, p, fldPath)...)

if p.HostAffinity != "" {
if len(p.HostIDs) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("hostIDs"), "a hostID must be specified when hostAffinity is set"))
}
switch p.HostAffinity {
case aws.HostAffinityDefault:
case aws.HostAffinityHost:
default:
allErrs = append(allErrs, field.Invalid(fldPath.Child("hostAffinity"), p.HostAffinity, "hostAffinity must be either default or host"))
}
}

return allErrs
}

Expand Down
20 changes: 20 additions & 0 deletions pkg/types/aws/validation/machinepool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,26 @@ func TestValidateMachinePool(t *testing.T) {
},
expected: `^test-path\.authentication: Invalid value: \"foobarbaz\": must be either Required or Optional$`,
},
{
name: "valid dedicated hosts",
platform: &aws.MachinePool{
HostAffinity: "default",
HostID: "h-09dcf61cb388b0149",
},
},
{
name: "invalid dedicated hosts - invalid affinity type",
platform: &aws.MachinePool{
HostAffinity: "unknown",
HostID: "h-09dcf61cb388b0149",
},
},
{
name: "invalid dedicated hosts - missing hostID",
platform: &aws.MachinePool{
HostAffinity: "host",
},
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
Expand Down