mirror of https://github.com/kubernetes/kops.git
Refactor LaunchTemplate.RootVolumeSize
This commit is contained in:
parent
3097a3a746
commit
1a39c9060e
|
|
@ -139,6 +139,14 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde
|
||||||
return nil, fmt.Errorf("unable to find IAM profile link for instance group %q: %w", ig.ObjectMeta.Name, err)
|
return nil, fmt.Errorf("unable to find IAM profile link for instance group %q: %w", ig.ObjectMeta.Name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rootVolumeSize, err := defaults.DefaultInstanceGroupVolumeSize(ig.Spec.Role)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if fi.Int32Value(ig.Spec.RootVolumeSize) > 0 {
|
||||||
|
rootVolumeSize = fi.Int32Value(ig.Spec.RootVolumeSize)
|
||||||
|
}
|
||||||
|
|
||||||
rootVolumeType := fi.StringValue(ig.Spec.RootVolumeType)
|
rootVolumeType := fi.StringValue(ig.Spec.RootVolumeType)
|
||||||
if rootVolumeType == "" {
|
if rootVolumeType == "" {
|
||||||
rootVolumeType = DefaultVolumeType
|
rootVolumeType = DefaultVolumeType
|
||||||
|
|
@ -162,7 +170,7 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde
|
||||||
InstanceType: fi.String(strings.Split(ig.Spec.MachineType, ",")[0]),
|
InstanceType: fi.String(strings.Split(ig.Spec.MachineType, ",")[0]),
|
||||||
RootVolumeIops: fi.Int64(int64(fi.Int32Value(ig.Spec.RootVolumeIops))),
|
RootVolumeIops: fi.Int64(int64(fi.Int32Value(ig.Spec.RootVolumeIops))),
|
||||||
RootVolumeOptimization: ig.Spec.RootVolumeOptimization,
|
RootVolumeOptimization: ig.Spec.RootVolumeOptimization,
|
||||||
RootVolumeSize: lc.RootVolumeSize,
|
RootVolumeSize: fi.Int64(int64(rootVolumeSize)),
|
||||||
RootVolumeType: fi.String(rootVolumeType),
|
RootVolumeType: fi.String(rootVolumeType),
|
||||||
RootVolumeEncryption: lc.RootVolumeEncryption,
|
RootVolumeEncryption: lc.RootVolumeEncryption,
|
||||||
SSHKey: lc.SSHKey,
|
SSHKey: lc.SSHKey,
|
||||||
|
|
@ -279,14 +287,7 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde
|
||||||
|
|
||||||
// buildLaunchTemplateHelper is responsible for building a launch configuration task into the model
|
// buildLaunchTemplateHelper is responsible for building a launch configuration task into the model
|
||||||
func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateHelper(c *fi.ModelBuilderContext, name string, ig *kops.InstanceGroup) (*awstasks.LaunchTemplate, error) {
|
func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateHelper(c *fi.ModelBuilderContext, name string, ig *kops.InstanceGroup) (*awstasks.LaunchTemplate, error) {
|
||||||
// @step: lets add the root volume settings
|
var err error
|
||||||
volumeSize, err := defaults.DefaultInstanceGroupVolumeSize(ig.Spec.Role)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if fi.Int32Value(ig.Spec.RootVolumeSize) > 0 {
|
|
||||||
volumeSize = fi.Int32Value(ig.Spec.RootVolumeSize)
|
|
||||||
}
|
|
||||||
|
|
||||||
rootVolumeEncryption := DefaultVolumeEncryption
|
rootVolumeEncryption := DefaultVolumeEncryption
|
||||||
if ig.Spec.RootVolumeEncryption != nil {
|
if ig.Spec.RootVolumeEncryption != nil {
|
||||||
|
|
@ -307,7 +308,6 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateHelper(c *fi.ModelBuil
|
||||||
t := &awstasks.LaunchTemplate{
|
t := &awstasks.LaunchTemplate{
|
||||||
Name: fi.String(name),
|
Name: fi.String(name),
|
||||||
Lifecycle: b.Lifecycle,
|
Lifecycle: b.Lifecycle,
|
||||||
RootVolumeSize: fi.Int64(int64(volumeSize)),
|
|
||||||
RootVolumeEncryption: fi.Bool(rootVolumeEncryption),
|
RootVolumeEncryption: fi.Bool(rootVolumeEncryption),
|
||||||
SecurityGroups: []*awstasks.SecurityGroup{sgLink},
|
SecurityGroups: []*awstasks.SecurityGroup{sgLink},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue