Skip to content
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
130 changes: 93 additions & 37 deletions pkg/model/awsmodel/api_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,27 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error {
}

if b.Cluster.UsesNoneDNS() {
nlbListener := &awstasks.NetworkLoadBalancerListener{
Name: fi.PtrTo(b.NLBListenerName("api", wellknownports.KopsControllerPort)),
Lifecycle: b.Lifecycle,
NetworkLoadBalancer: b.LinkToNLB("api"),
Port: wellknownports.KopsControllerPort,
TargetGroup: b.LinkToTargetGroup("kops-controller"),
{
nlbListener := &awstasks.NetworkLoadBalancerListener{
Name: fi.PtrTo(b.NLBListenerName("api", wellknownports.KopsControllerPort)),
Lifecycle: b.Lifecycle,
NetworkLoadBalancer: b.LinkToNLB("api"),
Port: wellknownports.KopsControllerPort,
TargetGroup: b.LinkToTargetGroup("kops-controller"),
}
nlbListeners = append(nlbListeners, nlbListener)
}

if b.Cluster.Spec.Networking.Cilium != nil && b.Cluster.Spec.Networking.Cilium.EtcdManaged {
nlbListener := &awstasks.NetworkLoadBalancerListener{
Name: fi.PtrTo(b.NLBListenerName("etcd-cilium", wellknownports.EtcdCiliumClientPort)),
Lifecycle: b.Lifecycle,
NetworkLoadBalancer: b.LinkToNLB("api"),
Port: wellknownports.EtcdCiliumClientPort,
TargetGroup: b.LinkToTargetGroup("etcd-cilium"),
}
nlbListeners = append(nlbListeners, nlbListener)
}
nlbListeners = append(nlbListeners, nlbListener)
}

if lbSpec.SecurityGroupOverride != nil {
Expand Down Expand Up @@ -328,28 +341,55 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error {
}

if b.Cluster.UsesNoneDNS() {
groupName := b.NLBTargetGroupName("kops-controller")
groupTags := b.CloudTags(groupName, false)

// Override the returned name to be the expected NLB TG name
groupTags["Name"] = groupName
{
groupName := b.NLBTargetGroupName("kops-controller")
groupTags := b.CloudTags(groupName, false)

// Override the returned name to be the expected NLB TG name
groupTags["Name"] = groupName

tg := &awstasks.TargetGroup{
Name: fi.PtrTo(groupName),
Lifecycle: b.Lifecycle,
VPC: b.LinkToVPC(),
Tags: groupTags,
Protocol: elbv2types.ProtocolEnumTcp,
Port: fi.PtrTo(int32(wellknownports.KopsControllerPort)),
Attributes: groupAttrs,
Interval: fi.PtrTo(int32(10)),
HealthyThreshold: fi.PtrTo(int32(2)),
UnhealthyThreshold: fi.PtrTo(int32(2)),
Shared: fi.PtrTo(false),
}
tg.CreateNewRevisionsWith(nlb)

tg := &awstasks.TargetGroup{
Name: fi.PtrTo(groupName),
Lifecycle: b.Lifecycle,
VPC: b.LinkToVPC(),
Tags: groupTags,
Protocol: elbv2types.ProtocolEnumTcp,
Port: fi.PtrTo(int32(wellknownports.KopsControllerPort)),
Attributes: groupAttrs,
Interval: fi.PtrTo(int32(10)),
HealthyThreshold: fi.PtrTo(int32(2)),
UnhealthyThreshold: fi.PtrTo(int32(2)),
Shared: fi.PtrTo(false),
c.AddTask(tg)
}
tg.CreateNewRevisionsWith(nlb)

c.AddTask(tg)
if b.Cluster.Spec.Networking.Cilium != nil && b.Cluster.Spec.Networking.Cilium.EtcdManaged {
groupName := b.NLBTargetGroupName("etcd-cilium")
groupTags := b.CloudTags(groupName, false)

// Override the returned name to be the expected NLB TG name
groupTags["Name"] = groupName

tg := &awstasks.TargetGroup{
Name: fi.PtrTo(groupName),
Lifecycle: b.Lifecycle,
VPC: b.LinkToVPC(),
Tags: groupTags,
Protocol: elbv2types.ProtocolEnumTcp,
Port: fi.PtrTo(int32(wellknownports.EtcdCiliumClientPort)),
Attributes: groupAttrs,
Interval: fi.PtrTo(int32(10)),
HealthyThreshold: fi.PtrTo(int32(2)),
UnhealthyThreshold: fi.PtrTo(int32(2)),
Shared: fi.PtrTo(false),
}
tg.CreateNewRevisionsWith(nlb)

c.AddTask(tg)
}
}

if lbSpec.SSLCertificate != "" {
Expand Down Expand Up @@ -576,18 +616,34 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error {
ToPort: fi.PtrTo(int32(4)),
})
if b.Cluster.UsesNoneDNS() {
nlb.WellKnownServices = append(nlb.WellKnownServices, wellknownservices.KopsController)
clb.WellKnownServices = append(clb.WellKnownServices, wellknownservices.KopsController)
{
nlb.WellKnownServices = append(nlb.WellKnownServices, wellknownservices.KopsController)
clb.WellKnownServices = append(clb.WellKnownServices, wellknownservices.KopsController)

c.AddTask(&awstasks.SecurityGroupRule{
Name: fi.PtrTo(fmt.Sprintf("kops-controller-elb-to-cp%s", suffix)),
Lifecycle: b.SecurityLifecycle,
FromPort: fi.PtrTo(int32(wellknownports.KopsControllerPort)),
Protocol: fi.PtrTo("tcp"),
SecurityGroup: masterGroup.Task,
ToPort: fi.PtrTo(int32(wellknownports.KopsControllerPort)),
SourceGroup: lbSG,
})
}

c.AddTask(&awstasks.SecurityGroupRule{
Name: fi.PtrTo(fmt.Sprintf("kops-controller-elb-to-cp%s", suffix)),
Lifecycle: b.SecurityLifecycle,
FromPort: fi.PtrTo(int32(wellknownports.KopsControllerPort)),
Protocol: fi.PtrTo("tcp"),
SecurityGroup: masterGroup.Task,
ToPort: fi.PtrTo(int32(wellknownports.KopsControllerPort)),
SourceGroup: lbSG,
})
if b.Cluster.Spec.Networking.Cilium != nil && b.Cluster.Spec.Networking.Cilium.EtcdManaged {
nlb.WellKnownServices = append(nlb.WellKnownServices, wellknownservices.EtcdCilium)

c.AddTask(&awstasks.SecurityGroupRule{
Name: fi.PtrTo(fmt.Sprintf("etcd-cilium-elb-to-cp%s", suffix)),
Lifecycle: b.SecurityLifecycle,
FromPort: fi.PtrTo(int32(wellknownports.EtcdCiliumClientPort)),
Protocol: fi.PtrTo("tcp"),
SecurityGroup: masterGroup.Task,
ToPort: fi.PtrTo(int32(wellknownports.EtcdCiliumClientPort)),
SourceGroup: lbSG,
})
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/model/awsmodel/autoscalinggroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ func (b *AutoscalingGroupModelBuilder) buildAutoScalingGroupTask(c *fi.CloudupMo
t.TargetGroups = append(t.TargetGroups, b.LinkToTargetGroup("tcp"))
if b.Cluster.UsesNoneDNS() && ig.IsControlPlane() {
t.TargetGroups = append(t.TargetGroups, b.LinkToTargetGroup("kops-controller"))
if b.Cluster.Spec.Networking.Cilium != nil && b.Cluster.Spec.Networking.Cilium.EtcdManaged {
t.TargetGroups = append(t.TargetGroups, b.LinkToTargetGroup("etcd-cilium"))
}
}
if b.Cluster.Spec.API.LoadBalancer.SSLCertificate != "" {
t.TargetGroups = append(t.TargetGroups, b.LinkToTargetGroup("tls"))
Expand Down
3 changes: 3 additions & 0 deletions pkg/wellknownservices/wellknownservices.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ const (

// KopsController is the service where kops-controller listens.
KopsController WellKnownService = "kops-controller"

// EtcdCilium is the service where Cilium etcd listens.
EtcdCilium WellKnownService = "etcd-cilium"
)
Loading