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 Nov 27, 2024
1 parent c20703f commit 91f0b3b
Show file tree
Hide file tree
Showing 13 changed files with 350 additions and 66 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.23.0

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/digitalocean/godo v1.130.0
github.com/digitalocean/godo v1.131.0
github.com/go-logr/logr v1.4.2
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/digitalocean/godo v1.130.0 h1:DbJg0wvBxTkYjY5Q9S1mwzAZLd5Wht3r57yFH4yeMCk=
github.com/digitalocean/godo v1.130.0/go.mod h1:PU8JB6I1XYkQIdHFop8lLAY9ojp6M0XcU0TWaQSxbrc=
github.com/digitalocean/godo v1.131.0 h1:0WHymufAV5avpodT0h5/pucUVfO4v7biquOIqhLeROY=
github.com/digitalocean/godo v1.131.0/go.mod h1:PU8JB6I1XYkQIdHFop8lLAY9ojp6M0XcU0TWaQSxbrc=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/emicklei/go-restful/v3 v3.12.0 h1:y2DdzBAURM29NFF94q6RaY4vjIH1rtwDapwQtU84iWk=
Expand Down
8 changes: 8 additions & 0 deletions vendor/github.com/digitalocean/godo/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/github.com/digitalocean/godo/apps.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions vendor/github.com/digitalocean/godo/apps.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 19 additions & 11 deletions vendor/github.com/digitalocean/godo/databases.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 91f0b3b

Please sign in to comment.