Skip to content

Commit

Permalink
Merge pull request #6015 from spotinst/fix-lb-attachment
Browse files Browse the repository at this point in the history
Spotinst: Skip the creation of LoadBalancerAttachment tasks if Spotinst is enabled
  • Loading branch information
k8s-ci-robot committed Nov 13, 2018
2 parents 892d26e + 9db3567 commit 35f0eaa
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
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

0 comments on commit 35f0eaa

Please sign in to comment.