mirror of https://github.com/kubernetes/kops.git
Refactor LaunchTemplate.AssociatePublicIP
This commit is contained in:
parent
d04946d983
commit
4657cb94d6
|
@ -143,7 +143,6 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde
|
||||||
lt := &awstasks.LaunchTemplate{
|
lt := &awstasks.LaunchTemplate{
|
||||||
Name: fi.String(name),
|
Name: fi.String(name),
|
||||||
Lifecycle: b.Lifecycle,
|
Lifecycle: b.Lifecycle,
|
||||||
AssociatePublicIP: lc.AssociatePublicIP,
|
|
||||||
BlockDeviceMappings: lc.BlockDeviceMappings,
|
BlockDeviceMappings: lc.BlockDeviceMappings,
|
||||||
IAMInstanceProfile: lc.IAMInstanceProfile,
|
IAMInstanceProfile: lc.IAMInstanceProfile,
|
||||||
ImageID: lc.ImageID,
|
ImageID: lc.ImageID,
|
||||||
|
@ -162,6 +161,26 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde
|
||||||
HTTPTokens: lc.HTTPTokens,
|
HTTPTokens: lc.HTTPTokens,
|
||||||
HTTPPutResponseHopLimit: lc.HTTPPutResponseHopLimit,
|
HTTPPutResponseHopLimit: lc.HTTPPutResponseHopLimit,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// @step: check the subnets are ok and pull together an array for us
|
||||||
|
subnets, err := b.GatherSubnets(ig)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// @step: check if we can add an public ip to this subnet
|
||||||
|
switch subnets[0].Type {
|
||||||
|
case kops.SubnetTypePublic, kops.SubnetTypeUtility:
|
||||||
|
lt.AssociatePublicIP = fi.Bool(true)
|
||||||
|
if ig.Spec.AssociatePublicIP != nil {
|
||||||
|
lt.AssociatePublicIP = ig.Spec.AssociatePublicIP
|
||||||
|
}
|
||||||
|
case kops.SubnetTypePrivate:
|
||||||
|
lt.AssociatePublicIP = fi.Bool(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// When using a MixedInstances ASG, AWS requires the SpotPrice be defined on the ASG
|
// When using a MixedInstances ASG, AWS requires the SpotPrice be defined on the ASG
|
||||||
// rather than the LaunchTemplate or else it returns this error:
|
// rather than the LaunchTemplate or else it returns this error:
|
||||||
// You cannot use a launch template that is set to request Spot Instances (InstanceMarketOptions)
|
// You cannot use a launch template that is set to request Spot Instances (InstanceMarketOptions)
|
||||||
|
@ -361,23 +380,6 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateHelper(c *fi.ModelBuil
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// @step: check the subnets are ok and pull together an array for us
|
|
||||||
subnets, err := b.GatherSubnets(ig)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// @step: check if we can add an public ip to this subnet
|
|
||||||
switch subnets[0].Type {
|
|
||||||
case kops.SubnetTypePublic, kops.SubnetTypeUtility:
|
|
||||||
t.AssociatePublicIP = fi.Bool(true)
|
|
||||||
if ig.Spec.AssociatePublicIP != nil {
|
|
||||||
t.AssociatePublicIP = ig.Spec.AssociatePublicIP
|
|
||||||
}
|
|
||||||
case kops.SubnetTypePrivate:
|
|
||||||
t.AssociatePublicIP = fi.Bool(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
return t, nil
|
return t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ type LaunchTemplate struct {
|
||||||
// Lifecycle is the resource lifecycle
|
// Lifecycle is the resource lifecycle
|
||||||
Lifecycle *fi.Lifecycle
|
Lifecycle *fi.Lifecycle
|
||||||
|
|
||||||
// AssociatePublicIP indicates if a public ip address is assigned to instabces
|
// AssociatePublicIP indicates if a public ip address is assigned to instances
|
||||||
AssociatePublicIP *bool
|
AssociatePublicIP *bool
|
||||||
// BlockDeviceMappings is a block device mappings
|
// BlockDeviceMappings is a block device mappings
|
||||||
BlockDeviceMappings []*BlockDeviceMapping
|
BlockDeviceMappings []*BlockDeviceMapping
|
||||||
|
|
Loading…
Reference in New Issue