From 20850fe92c3ac72461028d9d554e1c2d987c31d0 Mon Sep 17 00:00:00 2001 From: Josh Vasilevsky Date: Wed, 27 Nov 2024 10:41:04 -0500 Subject: [PATCH] LBAAS: add lb ipv6 address as ingress --- cloud-controller-manager/do/loadbalancers.go | 36 ++++++++++++------ .../do/loadbalancers_test.go | 38 +++++++++++++++++++ 2 files changed, 63 insertions(+), 11 deletions(-) diff --git a/cloud-controller-manager/do/loadbalancers.go b/cloud-controller-manager/do/loadbalancers.go index 8e2ffe1ff..3814a476d 100644 --- a/cloud-controller-manager/do/loadbalancers.go +++ b/cloud-controller-manager/do/loadbalancers.go @@ -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 } @@ -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 { diff --git a/cloud-controller-manager/do/loadbalancers_test.go b/cloud-controller-manager/do/loadbalancers_test.go index 380fa1879..d6e43a442 100644 --- a/cloud-controller-manager/do/loadbalancers_test.go +++ b/cloud-controller-manager/do/loadbalancers_test.go @@ -132,6 +132,7 @@ func createLB() *godo.LoadBalancer { ID: "load-balancer-id", Name: "afoobar123", IP: "10.0.0.1", + IPv6: "fd53::b001", Status: lbStatusActive, } } @@ -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{ { @@ -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 @@ -5028,6 +5031,9 @@ func Test_GetLoadBalancer(t *testing.T) { { IP: "10.0.0.1", }, + { + IP: "fd53::b001", + }, }, }, exists: true, @@ -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 @@ -5071,6 +5078,9 @@ func Test_GetLoadBalancer(t *testing.T) { { IP: "10.0.0.1", }, + { + IP: "fd53::b001", + }, }, }, exists: true, @@ -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 @@ -5103,6 +5114,9 @@ func Test_GetLoadBalancer(t *testing.T) { { IP: "10.0.0.1", }, + { + IP: "fd53::b001", + }, }, }, exists: true, @@ -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 }, @@ -5147,6 +5162,9 @@ func Test_GetLoadBalancer(t *testing.T) { { IP: "10.0.0.1", }, + { + IP: "fd53::b001", + }, }, }, exists: true, @@ -5321,6 +5339,9 @@ func Test_EnsureLoadBalancer(t *testing.T) { { IP: "10.0.0.1", }, + { + IP: "fd53::b001", + }, }, }, err: nil, @@ -5395,6 +5416,9 @@ func Test_EnsureLoadBalancer(t *testing.T) { { IP: "10.0.0.1", }, + { + IP: "fd53::b001", + }, }, }, err: nil, @@ -5468,6 +5492,9 @@ func Test_EnsureLoadBalancer(t *testing.T) { { IP: "10.0.0.1", }, + { + IP: "fd53::b001", + }, }, }, err: nil, @@ -5545,6 +5572,9 @@ func Test_EnsureLoadBalancer(t *testing.T) { { IP: "10.0.0.1", }, + { + IP: "fd53::b001", + }, }, }, err: nil, @@ -5632,6 +5662,9 @@ func Test_EnsureLoadBalancer(t *testing.T) { { IP: "10.0.0.1", }, + { + IP: "fd53::b001", + }, }, }, }, @@ -5642,6 +5675,9 @@ func Test_EnsureLoadBalancer(t *testing.T) { { IP: "10.0.0.1", }, + { + IP: "fd53::b001", + }, }, }, err: nil, @@ -5758,6 +5794,7 @@ func Test_EnsureLoadBalancerDeleted(t *testing.T) { { Name: lbName, IP: "10.0.0.1", + IPv6: "fd53::b001", Status: lbStatusActive, }, }, newFakeOKResponse(), nil @@ -5780,6 +5817,7 @@ func Test_EnsureLoadBalancerDeleted(t *testing.T) { { Name: lbName, IP: "10.0.0.1", + IPv6: "fd53::b001", Status: lbStatusActive, }, }, newFakeOKResponse(), nil