Skip to content

Commit

Permalink
LBAAS: add lb ipv6 address as ingress
Browse files Browse the repository at this point in the history
  • Loading branch information
jvasilevsky committed Jan 6, 2025
1 parent d274be6 commit 20850fe
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 11 deletions.
36 changes: 25 additions & 11 deletions cloud-controller-manager/do/loadbalancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,20 @@ func (l *loadBalancers) GetLoadBalancer(ctx context.Context, clusterName string,
return nil, false, err
}

return &v1.LoadBalancerStatus{
Ingress: []v1.LoadBalancerIngress{
{
IP: lb.IP,
},
ingress := []v1.LoadBalancerIngress{
{
IP: lb.IP,
},
}

if lb.IPv6 != "" {
ingress = append(ingress, v1.LoadBalancerIngress{
IP: lb.IPv6,
})
}

return &v1.LoadBalancerStatus{
Ingress: ingress,
}, true, nil
}

Expand Down Expand Up @@ -244,13 +252,19 @@ func (l *loadBalancers) EnsureLoadBalancer(ctx context.Context, clusterName stri
}, nil
}

return &v1.LoadBalancerStatus{
Ingress: []v1.LoadBalancerIngress{
{
IP: lb.IP,
},
ingress := []v1.LoadBalancerIngress{
{
IP: lb.IP,
},
}, nil
}

if lb.IPv6 != "" {
ingress = append(ingress, v1.LoadBalancerIngress{
IP: lb.IPv6,
})
}

return &v1.LoadBalancerStatus{Ingress: ingress}, nil
}

func getCertificateIDFromLB(lb *godo.LoadBalancer) string {
Expand Down
38 changes: 38 additions & 0 deletions cloud-controller-manager/do/loadbalancers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ func createLB() *godo.LoadBalancer {
ID: "load-balancer-id",
Name: "afoobar123",
IP: "10.0.0.1",
IPv6: "fd53::b001",
Status: lbStatusActive,
}
}
Expand All @@ -141,6 +142,7 @@ func createHTTPSLB(lbID, certID, certType string) (*godo.LoadBalancer, *godo.Cer
ID: lbID,
Name: "afoobar123",
IP: "10.0.0.1",
IPv6: "fd53::b001",
Status: lbStatusActive,
ForwardingRules: []godo.ForwardingRule{
{
Expand Down Expand Up @@ -4999,6 +5001,7 @@ func Test_GetLoadBalancer(t *testing.T) {
ID: "load-balancer-id",
Name: "afoobar123",
IP: "10.0.0.1",
IPv6: "fd53::b001",
Status: lbStatusActive,
},
}, newFakeOKResponse(), nil
Expand Down Expand Up @@ -5028,6 +5031,9 @@ func Test_GetLoadBalancer(t *testing.T) {
{
IP: "10.0.0.1",
},
{
IP: "fd53::b001",
},
},
},
exists: true,
Expand All @@ -5041,6 +5047,7 @@ func Test_GetLoadBalancer(t *testing.T) {
ID: "load-balancer-id",
Name: "my-load-balancer-123",
IP: "10.0.0.1",
IPv6: "fd53::b001",
Status: lbStatusActive,
},
}, newFakeOKResponse(), nil
Expand Down Expand Up @@ -5071,6 +5078,9 @@ func Test_GetLoadBalancer(t *testing.T) {
{
IP: "10.0.0.1",
},
{
IP: "fd53::b001",
},
},
},
exists: true,
Expand All @@ -5084,6 +5094,7 @@ func Test_GetLoadBalancer(t *testing.T) {
ID: "load-balancer-id",
Name: "afoobar123",
IP: "10.0.0.1",
IPv6: "fd53::b001",
Status: lbStatusActive,
},
}, newFakeOKResponse(), nil
Expand All @@ -5103,6 +5114,9 @@ func Test_GetLoadBalancer(t *testing.T) {
{
IP: "10.0.0.1",
},
{
IP: "fd53::b001",
},
},
},
exists: true,
Expand All @@ -5115,6 +5129,7 @@ func Test_GetLoadBalancer(t *testing.T) {
ID: "load-balancer-id",
Name: "afoobar123",
IP: "10.0.0.1",
IPv6: "fd53::b001",
Status: lbStatusActive,
}, newFakeOKResponse(), nil
},
Expand Down Expand Up @@ -5147,6 +5162,9 @@ func Test_GetLoadBalancer(t *testing.T) {
{
IP: "10.0.0.1",
},
{
IP: "fd53::b001",
},
},
},
exists: true,
Expand Down Expand Up @@ -5321,6 +5339,9 @@ func Test_EnsureLoadBalancer(t *testing.T) {
{
IP: "10.0.0.1",
},
{
IP: "fd53::b001",
},
},
},
err: nil,
Expand Down Expand Up @@ -5395,6 +5416,9 @@ func Test_EnsureLoadBalancer(t *testing.T) {
{
IP: "10.0.0.1",
},
{
IP: "fd53::b001",
},
},
},
err: nil,
Expand Down Expand Up @@ -5468,6 +5492,9 @@ func Test_EnsureLoadBalancer(t *testing.T) {
{
IP: "10.0.0.1",
},
{
IP: "fd53::b001",
},
},
},
err: nil,
Expand Down Expand Up @@ -5545,6 +5572,9 @@ func Test_EnsureLoadBalancer(t *testing.T) {
{
IP: "10.0.0.1",
},
{
IP: "fd53::b001",
},
},
},
err: nil,
Expand Down Expand Up @@ -5632,6 +5662,9 @@ func Test_EnsureLoadBalancer(t *testing.T) {
{
IP: "10.0.0.1",
},
{
IP: "fd53::b001",
},
},
},
},
Expand All @@ -5642,6 +5675,9 @@ func Test_EnsureLoadBalancer(t *testing.T) {
{
IP: "10.0.0.1",
},
{
IP: "fd53::b001",
},
},
},
err: nil,
Expand Down Expand Up @@ -5758,6 +5794,7 @@ func Test_EnsureLoadBalancerDeleted(t *testing.T) {
{
Name: lbName,
IP: "10.0.0.1",
IPv6: "fd53::b001",
Status: lbStatusActive,
},
}, newFakeOKResponse(), nil
Expand All @@ -5780,6 +5817,7 @@ func Test_EnsureLoadBalancerDeleted(t *testing.T) {
{
Name: lbName,
IP: "10.0.0.1",
IPv6: "fd53::b001",
Status: lbStatusActive,
},
}, newFakeOKResponse(), nil
Expand Down

0 comments on commit 20850fe

Please sign in to comment.