Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spotinst: Skip the creation of LoadBalancerAttachment tasks if Spotinst is enabled #6015

Merged
merged 1 commit into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/model/awsmodel/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ go_library(
deps = [
"//pkg/apis/kops:go_default_library",
"//pkg/dns:go_default_library",
"//pkg/featureflag:go_default_library",
"//pkg/model:go_default_library",
"//pkg/model/defaults:go_default_library",
"//upup/pkg/fi:go_default_library",
Expand Down
22 changes: 14 additions & 8 deletions pkg/model/awsmodel/api_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/dns"
"k8s.io/kops/pkg/featureflag"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/cloudup/awstasks"
"k8s.io/kops/upup/pkg/fi/fitasks"
Expand Down Expand Up @@ -254,16 +255,21 @@ func (b *APILoadBalancerBuilder) Build(c *fi.ModelBuilderContext) error {
masterKeypair.AlternateNameTasks = append(masterKeypair.AlternateNameTasks, elb)
}

for _, ig := range b.MasterInstanceGroups() {
t := &awstasks.LoadBalancerAttachment{
Name: s("api-" + ig.ObjectMeta.Name),
Lifecycle: b.Lifecycle,
// When Spotinst Elastigroups are used, there is no need to create
// a separate task for the attachment of the load balancer since this
// is already done as part of the Elastigroup's creation, if needed.
if !featureflag.Spotinst.Enabled() {
for _, ig := range b.MasterInstanceGroups() {
t := &awstasks.LoadBalancerAttachment{
Name: s("api-" + ig.ObjectMeta.Name),
Lifecycle: b.Lifecycle,

LoadBalancer: b.LinkToELB("api"),
AutoscalingGroup: b.LinkToAutoscalingGroup(ig),
}

LoadBalancer: b.LinkToELB("api"),
AutoscalingGroup: b.LinkToAutoscalingGroup(ig),
c.AddTask(t)
}

c.AddTask(t)
}

return nil
Expand Down
24 changes: 15 additions & 9 deletions pkg/model/bastion.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/featureflag"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/cloudup/awstasks"
)
Expand Down Expand Up @@ -236,18 +237,23 @@ func (b *BastionModelBuilder) Build(c *fi.ModelBuilderContext) error {
c.AddTask(elb)
}

for _, ig := range bastionInstanceGroups {
// We build the ASG when we iterate over the instance groups
// When Spotinst Elastigroups are used, there is no need to create
// a separate task for the attachment of the load balancer since this
// is already done as part of the Elastigroup's creation, if needed.
if !featureflag.Spotinst.Enabled() {
for _, ig := range bastionInstanceGroups {
// We build the ASG when we iterate over the instance groups

// Attach the ELB to the ASG
t := &awstasks.LoadBalancerAttachment{
Name: s("bastion-elb-attachment"),
Lifecycle: b.Lifecycle,
// Attach the ELB to the ASG
t := &awstasks.LoadBalancerAttachment{
Name: s("bastion-elb-attachment"),
Lifecycle: b.Lifecycle,

LoadBalancer: elb,
AutoscalingGroup: b.LinkToAutoscalingGroup(ig),
LoadBalancer: elb,
AutoscalingGroup: b.LinkToAutoscalingGroup(ig),
}
c.AddTask(t)
}
c.AddTask(t)
}

bastionPublicName := ""
Expand Down