Skip to content

Commit

Permalink
Allow changing settings on an owned LB
Browse files Browse the repository at this point in the history
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
  • Loading branch information
mikkeloscar committed Aug 25, 2022
1 parent 58ece4c commit b593285
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
27 changes: 17 additions & 10 deletions worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,6 @@ func (l *loadBalancer) addIngress(certificateARNs []string, ingress *kubernetes.
return true
}

if l.ipAddressType != ingress.IPAddressType ||
l.scheme != ingress.Scheme ||
l.securityGroup != ingress.SecurityGroup ||
l.sslPolicy != ingress.SSLPolicy ||
l.loadBalancerType != ingress.LoadBalancerType ||
l.http2 != ingress.HTTP2 ||
l.wafWebACLID != ingress.WAFWebACLID {
return false
}

resourceName := fmt.Sprintf("%s/%s", ingress.Namespace, ingress.Name)

owner := ""
Expand All @@ -113,6 +103,23 @@ func (l *loadBalancer) addIngress(certificateARNs []string, ingress *kubernetes.
return false
}

// settings that would require a new load balancer no matter if it's
// shared or not.
if l.ipAddressType != ingress.IPAddressType ||
l.scheme != ingress.Scheme ||
l.loadBalancerType != ingress.LoadBalancerType ||
l.http2 != ingress.HTTP2 {
return false
}

// settings that can be changed on an existing load balancer if it's
// NOT shared.
if ingress.Shared && (l.securityGroup != ingress.SecurityGroup ||
l.sslPolicy != ingress.SSLPolicy ||
l.wafWebACLID != ingress.WAFWebACLID) {
return false
}

// check if we can fit the ingress on the load balancer based on
// maxCerts
newCerts := 0
Expand Down
21 changes: 20 additions & 1 deletion worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,31 @@ func TestAddIngress(tt *testing.T) {
},
added: false,
},
{
name: "Adding/changing WAF, SG or TLS settings on non-shared LB should work",
loadBalancer: &loadBalancer{
ingresses: make(map[string][]*kubernetes.Ingress),
stack: &aws.Stack{
OwnerIngress: "foo/bar",
},
sslPolicy: "ELBSecurityPolicy-2016-08",
},
ingress: &kubernetes.Ingress{
Name: "bar",
Namespace: "foo",
WAFWebACLID: "WAFZXX",
SecurityGroup: "bar",
SSLPolicy: "ELBSecurityPolicy-FS-2018-06",
Shared: false,
},
added: true,
},
} {
tt.Run(test.name, func(t *testing.T) {
assert.Equal(
t,
test.loadBalancer.addIngress(test.certificateARNs, test.ingress, test.maxCerts),
test.added,
test.loadBalancer.addIngress(test.certificateARNs, test.ingress, test.maxCerts),
)
})
}
Expand Down

0 comments on commit b593285

Please sign in to comment.