mirror of https://github.com/kubernetes/kops.git
Merge pull request #8261 from appvia/lt-rolling-updates
Fix RollingUpdate behaviour when using LaunchTemplates for both kops & terraform spec updates
This commit is contained in:
commit
c345b9333f
|
|
@ -20,6 +20,7 @@ import (
|
|||
"fmt"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
|
|
@ -30,6 +31,7 @@ import (
|
|||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
|
|
@ -271,6 +273,7 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
|||
LaunchTemplateName: e.LaunchTemplate.ID,
|
||||
}
|
||||
}
|
||||
|
||||
// @check if we are using mixed instance policies
|
||||
if e.UseMixedInstancesPolicy() {
|
||||
// we can zero this out for now and use the mixed instance policy for definition
|
||||
|
|
@ -284,7 +287,7 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
|||
SpotMaxPrice: e.MixedSpotMaxPrice,
|
||||
},
|
||||
LaunchTemplate: &autoscaling.LaunchTemplate{
|
||||
LaunchTemplateSpecification: &autoscaling.LaunchTemplateSpecification{LaunchTemplateName: e.LaunchTemplate.ID},
|
||||
LaunchTemplateSpecification: &autoscaling.LaunchTemplateSpecification{LaunchTemplateName: e.LaunchTemplate.ID, Version: aws.String("1")},
|
||||
},
|
||||
}
|
||||
p := request.MixedInstancesPolicy.LaunchTemplate
|
||||
|
|
@ -345,12 +348,26 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
|||
return req.MixedInstancesPolicy
|
||||
}
|
||||
|
||||
launchTemplateVersion := "1"
|
||||
if e.LaunchTemplate != nil {
|
||||
dltRequest := &ec2.DescribeLaunchTemplatesInput{
|
||||
LaunchTemplateNames: []*string{e.LaunchTemplate.ID},
|
||||
}
|
||||
dltResponse, err := t.Cloud.EC2().DescribeLaunchTemplates(dltRequest)
|
||||
if err != nil {
|
||||
klog.Warningf("could not find existing LaunchTemplate: %v", err)
|
||||
} else {
|
||||
launchTemplateVersion = strconv.FormatInt(*dltResponse.LaunchTemplates[0].LatestVersionNumber, 10)
|
||||
}
|
||||
}
|
||||
|
||||
if changes.LaunchTemplate != nil {
|
||||
// @note: at the moment we are only using launch templates when using mixed instance policies,
|
||||
// but this might change
|
||||
setup(request).LaunchTemplate = &autoscaling.LaunchTemplate{
|
||||
LaunchTemplateSpecification: &autoscaling.LaunchTemplateSpecification{
|
||||
LaunchTemplateName: changes.LaunchTemplate.ID,
|
||||
Version: &launchTemplateVersion,
|
||||
},
|
||||
}
|
||||
changes.LaunchTemplate = nil
|
||||
|
|
@ -381,6 +398,7 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
|||
setup(request).LaunchTemplate = &autoscaling.LaunchTemplate{
|
||||
LaunchTemplateSpecification: &autoscaling.LaunchTemplateSpecification{
|
||||
LaunchTemplateName: e.LaunchTemplate.ID,
|
||||
Version: &launchTemplateVersion,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue