diff --git a/docs/user/aws/customization.md b/docs/user/aws/customization.md index c63e73c685..48bd04b68b 100644 --- a/docs/user/aws/customization.md +++ b/docs/user/aws/customization.md @@ -25,6 +25,8 @@ Beyond the [platform-agnostic `install-config.yaml` properties](../customization Example ARN values are: `arn:aws:kms:us-east-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab` or `arn:aws:kms:us-east-1:111122223333:alias/my-key` * `type` (optional string): The [EC2 instance type][instance-type]. * `zones` (optional array of strings): The availability zones used for machines in the pool. +* `amiID` (optional string): The AMI that should be used to boot machines. + If set, the AMI should belong to the same region as the cluster. ## Examples @@ -67,6 +69,7 @@ compute: - name: worker platform: aws: + amiID: ami-123456 rootVolume: iops: 4000 size: 500 diff --git a/pkg/asset/machines/aws/machines.go b/pkg/asset/machines/aws/machines.go index 5dbdd60d54..a75e1891f2 100644 --- a/pkg/asset/machines/aws/machines.go +++ b/pkg/asset/machines/aws/machines.go @@ -18,7 +18,7 @@ import ( ) // Machines returns a list of machines for a machinepool. -func Machines(clusterID string, region string, subnets map[string]string, pool *types.MachinePool, osImage, role, userDataSecret string, userTags map[string]string) ([]machineapi.Machine, error) { +func Machines(clusterID string, region string, subnets map[string]string, pool *types.MachinePool, role, userDataSecret string, userTags map[string]string) ([]machineapi.Machine, error) { if poolPlatform := pool.Platform.Name(); poolPlatform != aws.Name { return nil, fmt.Errorf("non-AWS machine-pool: %q", poolPlatform) } @@ -41,7 +41,7 @@ func Machines(clusterID string, region string, subnets map[string]string, pool * subnet, mpool.InstanceType, &mpool.EC2RootVolume, - osImage, + mpool.AMIID, zone, role, userDataSecret, diff --git a/pkg/asset/machines/aws/machinesets.go b/pkg/asset/machines/aws/machinesets.go index 9032a7b31f..aac1ce9dbb 100644 --- a/pkg/asset/machines/aws/machinesets.go +++ b/pkg/asset/machines/aws/machinesets.go @@ -14,7 +14,7 @@ import ( ) // MachineSets returns a list of machinesets for a machinepool. -func MachineSets(clusterID string, region string, subnets map[string]string, pool *types.MachinePool, osImage, role, userDataSecret string, userTags map[string]string) ([]*machineapi.MachineSet, error) { +func MachineSets(clusterID string, region string, subnets map[string]string, pool *types.MachinePool, role, userDataSecret string, userTags map[string]string) ([]*machineapi.MachineSet, error) { if poolPlatform := pool.Platform.Name(); poolPlatform != aws.Name { return nil, fmt.Errorf("non-AWS machine-pool: %q", poolPlatform) } @@ -43,7 +43,7 @@ func MachineSets(clusterID string, region string, subnets map[string]string, poo subnet, mpool.InstanceType, &mpool.EC2RootVolume, - osImage, + mpool.AMIID, az, role, userDataSecret, diff --git a/pkg/asset/machines/master.go b/pkg/asset/machines/master.go index 111b43fdc8..e7bce718dd 100644 --- a/pkg/asset/machines/master.go +++ b/pkg/asset/machines/master.go @@ -159,6 +159,7 @@ func (m *Master) Generate(dependencies asset.Parents) error { } mpool := defaultAWSMachinePoolPlatform() + mpool.AMIID = string(*rhcosImage) mpool.Set(ic.Platform.AWS.DefaultMachinePlatform) mpool.Set(pool.Platform.AWS) if len(mpool.Zones) == 0 { @@ -187,7 +188,6 @@ func (m *Master) Generate(dependencies asset.Parents) error { installConfig.Config.Platform.AWS.Region, subnets, pool, - string(*rhcosImage), "master", "master-user-data", installConfig.Config.Platform.AWS.UserTags, diff --git a/pkg/asset/machines/worker.go b/pkg/asset/machines/worker.go index 3d5071f9ae..f3f758eb0a 100644 --- a/pkg/asset/machines/worker.go +++ b/pkg/asset/machines/worker.go @@ -195,6 +195,7 @@ func (w *Worker) Generate(dependencies asset.Parents) error { } mpool := defaultAWSMachinePoolPlatform() + mpool.AMIID = string(*rhcosImage) mpool.Set(ic.Platform.AWS.DefaultMachinePlatform) mpool.Set(pool.Platform.AWS) if len(mpool.Zones) == 0 { @@ -222,7 +223,6 @@ func (w *Worker) Generate(dependencies asset.Parents) error { installConfig.Config.Platform.AWS.Region, subnets, &pool, - string(*rhcosImage), "worker", "worker-user-data", installConfig.Config.Platform.AWS.UserTags, diff --git a/pkg/types/aws/machinepool.go b/pkg/types/aws/machinepool.go index 8453f8e984..71efa86930 100644 --- a/pkg/types/aws/machinepool.go +++ b/pkg/types/aws/machinepool.go @@ -10,6 +10,10 @@ type MachinePool struct { // eg. m4-large InstanceType string `json:"type"` + // 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. + AMIID string `json:"amiID,omitempty"` + // EC2RootVolume defines the root volume for EC2 instances in the machine pool. EC2RootVolume `json:"rootVolume"` } @@ -28,6 +32,10 @@ func (a *MachinePool) Set(required *MachinePool) { a.InstanceType = required.InstanceType } + if required.AMIID != "" { + a.AMIID = required.AMIID + } + if required.EC2RootVolume.IOPS != 0 { a.EC2RootVolume.IOPS = required.EC2RootVolume.IOPS }