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"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"k8s.io/kops/upup/pkg/fi"
|
"k8s.io/kops/upup/pkg/fi"
|
||||||
|
|
@ -30,6 +31,7 @@ import (
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||||
|
"github.com/aws/aws-sdk-go/service/ec2"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -271,6 +273,7 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
||||||
LaunchTemplateName: e.LaunchTemplate.ID,
|
LaunchTemplateName: e.LaunchTemplate.ID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @check if we are using mixed instance policies
|
// @check if we are using mixed instance policies
|
||||||
if e.UseMixedInstancesPolicy() {
|
if e.UseMixedInstancesPolicy() {
|
||||||
// we can zero this out for now and use the mixed instance policy for definition
|
// 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,
|
SpotMaxPrice: e.MixedSpotMaxPrice,
|
||||||
},
|
},
|
||||||
LaunchTemplate: &autoscaling.LaunchTemplate{
|
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
|
p := request.MixedInstancesPolicy.LaunchTemplate
|
||||||
|
|
@ -345,12 +348,26 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
||||||
return req.MixedInstancesPolicy
|
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 {
|
if changes.LaunchTemplate != nil {
|
||||||
// @note: at the moment we are only using launch templates when using mixed instance policies,
|
// @note: at the moment we are only using launch templates when using mixed instance policies,
|
||||||
// but this might change
|
// but this might change
|
||||||
setup(request).LaunchTemplate = &autoscaling.LaunchTemplate{
|
setup(request).LaunchTemplate = &autoscaling.LaunchTemplate{
|
||||||
LaunchTemplateSpecification: &autoscaling.LaunchTemplateSpecification{
|
LaunchTemplateSpecification: &autoscaling.LaunchTemplateSpecification{
|
||||||
LaunchTemplateName: changes.LaunchTemplate.ID,
|
LaunchTemplateName: changes.LaunchTemplate.ID,
|
||||||
|
Version: &launchTemplateVersion,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
changes.LaunchTemplate = nil
|
changes.LaunchTemplate = nil
|
||||||
|
|
@ -381,6 +398,7 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
||||||
setup(request).LaunchTemplate = &autoscaling.LaunchTemplate{
|
setup(request).LaunchTemplate = &autoscaling.LaunchTemplate{
|
||||||
LaunchTemplateSpecification: &autoscaling.LaunchTemplateSpecification{
|
LaunchTemplateSpecification: &autoscaling.LaunchTemplateSpecification{
|
||||||
LaunchTemplateName: e.LaunchTemplate.ID,
|
LaunchTemplateName: e.LaunchTemplate.ID,
|
||||||
|
Version: &launchTemplateVersion,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue