1
0
mirror of https://github.com/openshift/installer.git synced 2026-02-05 15:47:14 +01:00

aws: allow users to provide AMI for each machine pool

users can set AMI for the platform or defaultMachinePool or individual machine pool, and the AMI used is based on increasing order of priority of the list mentioned before.
This commit is contained in:
Abhinav Dahiya
2020-03-17 16:37:09 -07:00
parent 344e38f31f
commit bc47222576
6 changed files with 17 additions and 6 deletions

View File

@@ -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

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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
}