Skip to content

Commit 2b44b2b

Browse files
authored
CON-12387 Ensure NLB is the default loadbalancer in DO CCM (#830)
1 parent 87f2367 commit 2b44b2b

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

cloud-controller-manager/do/certificates_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ func createService(lbID string) *v1.Service {
126126
Annotations: map[string]string{
127127
annDOProtocol: "http",
128128
annDOLoadBalancerID: lbID,
129+
annDOType: godo.LoadBalancerTypeRegional,
129130
},
130131
},
131132
Spec: v1.ServiceSpec{

cloud-controller-manager/do/firewall_controller_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,9 @@ func TestFirewallController_createReconciledFirewallRequest(t *testing.T) {
359359
ObjectMeta: metav1.ObjectMeta{
360360
Name: "lbServiceType",
361361
UID: "abc12345",
362+
Annotations: map[string]string{
363+
annDOType: godo.LoadBalancerTypeRegional,
364+
},
362365
},
363366
Spec: v1.ServiceSpec{
364367
Type: v1.ServiceTypeLoadBalancer,

cloud-controller-manager/do/loadbalancers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ func getDisownLB(service *v1.Service) (bool, error) {
14271427
func getType(service *v1.Service) (string, error) {
14281428
name, ok := service.Annotations[annDOType]
14291429
if !ok || name == "" {
1430-
return godo.LoadBalancerTypeRegional, nil
1430+
return godo.LoadBalancerTypeRegionalNetwork, nil
14311431
}
14321432
if !(name == godo.LoadBalancerTypeRegional || name == godo.LoadBalancerTypeRegionalNetwork) {
14331433
return "", fmt.Errorf("only LB types supported are (%s, %s)", godo.LoadBalancerTypeRegional, godo.LoadBalancerTypeRegionalNetwork)

cloud-controller-manager/do/loadbalancers_test.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3647,6 +3647,7 @@ func Test_buildLoadBalancerRequest(t *testing.T) {
36473647
UID: "foobar123",
36483648
Annotations: map[string]string{
36493649
annDOProtocol: "http",
3650+
annDOType: godo.LoadBalancerTypeRegional,
36503651
},
36513652
},
36523653
Spec: v1.ServiceSpec{
@@ -3725,6 +3726,7 @@ func Test_buildLoadBalancerRequest(t *testing.T) {
37253726
Annotations: map[string]string{
37263727
annDOProtocol: "http2",
37273728
annDOCertificateID: "test-certificate",
3729+
annDOType: godo.LoadBalancerTypeRegional,
37283730
},
37293731
},
37303732
Spec: v1.ServiceSpec{
@@ -3803,6 +3805,7 @@ func Test_buildLoadBalancerRequest(t *testing.T) {
38033805
Annotations: map[string]string{
38043806
annDOProtocol: "http2",
38053807
annDOCertificateID: "test-certificate",
3808+
annDOType: godo.LoadBalancerTypeRegional,
38063809
},
38073810
},
38083811
Spec: v1.ServiceSpec{
@@ -3892,6 +3895,7 @@ func Test_buildLoadBalancerRequest(t *testing.T) {
38923895
UID: "foobar123",
38933896
Annotations: map[string]string{
38943897
annDOOverrideHealthCheck: "",
3898+
annDOType: godo.LoadBalancerTypeRegional,
38953899
},
38963900
},
38973901
Spec: v1.ServiceSpec{
@@ -3949,6 +3953,7 @@ func Test_buildLoadBalancerRequest(t *testing.T) {
39493953
annDOProtocol: "tcp",
39503954
annDOHealthCheckPath: "/health",
39513955
annDOHealthCheckProtocol: "http",
3956+
annDOType: godo.LoadBalancerTypeRegional,
39523957
},
39533958
},
39543959
Spec: v1.ServiceSpec{
@@ -4027,6 +4032,7 @@ func Test_buildLoadBalancerRequest(t *testing.T) {
40274032
Annotations: map[string]string{
40284033
annDOProtocol: "http",
40294034
annDOAlgorithm: "least_connections",
4035+
annDOType: godo.LoadBalancerTypeRegional,
40304036
},
40314037
},
40324038
Spec: v1.ServiceSpec{
@@ -4105,6 +4111,7 @@ func Test_buildLoadBalancerRequest(t *testing.T) {
41054111
Annotations: map[string]string{
41064112
annDOProtocol: "http",
41074113
annDOSizeSlug: "lb-medium",
4114+
annDOType: godo.LoadBalancerTypeRegional,
41084115
},
41094116
},
41104117
Spec: v1.ServiceSpec{
@@ -4184,6 +4191,7 @@ func Test_buildLoadBalancerRequest(t *testing.T) {
41844191
Annotations: map[string]string{
41854192
annDOProtocol: "http",
41864193
annDOSizeUnit: "2",
4194+
annDOType: godo.LoadBalancerTypeRegional,
41874195
},
41884196
},
41894197
Spec: v1.ServiceSpec{
@@ -4322,6 +4330,7 @@ func Test_buildLoadBalancerRequest(t *testing.T) {
43224330
annDOStickySessionsType: "cookies",
43234331
annDOStickySessionsCookieName: "DO-CCM",
43244332
annDOStickySessionsCookieTTL: "300",
4333+
annDOType: godo.LoadBalancerTypeRegional,
43254334
},
43264335
},
43274336
Spec: v1.ServiceSpec{
@@ -4405,6 +4414,7 @@ func Test_buildLoadBalancerRequest(t *testing.T) {
44054414
annDOStickySessionsType: "cookies",
44064415
annDOStickySessionsCookieName: "DO-CCM",
44074416
annDOStickySessionsCookieTTL: "300",
4417+
annDOType: godo.LoadBalancerTypeRegional,
44084418
},
44094419
},
44104420
Spec: v1.ServiceSpec{
@@ -4488,6 +4498,7 @@ func Test_buildLoadBalancerRequest(t *testing.T) {
44884498
annDORedirectHTTPToHTTPS: "true",
44894499
annDOTLSPorts: "443",
44904500
annDOCertificateID: "test-certificate",
4501+
annDOType: godo.LoadBalancerTypeRegional,
44914502
},
44924503
},
44934504
Spec: v1.ServiceSpec{
@@ -4582,6 +4593,7 @@ func Test_buildLoadBalancerRequest(t *testing.T) {
45824593
annDOTLSPorts: "443",
45834594
annDOCertificateID: "test-certificate",
45844595
annDODisableLetsEncryptDNSRecords: "true",
4596+
annDOType: godo.LoadBalancerTypeRegional,
45854597
},
45864598
},
45874599
Spec: v1.ServiceSpec{
@@ -6244,7 +6256,7 @@ func Test_getType(t *testing.T) {
62446256
expectedType *string
62456257
}{
62466258
{
6247-
name: "no value defaults to REGIONAL",
6259+
name: "no value defaults to REGIONAL_NETWORK",
62486260
service: &v1.Service{
62496261
ObjectMeta: metav1.ObjectMeta{
62506262
Name: "test",
@@ -6253,7 +6265,7 @@ func Test_getType(t *testing.T) {
62536265
},
62546266
},
62556267
wantErr: false,
6256-
expectedType: &regional,
6268+
expectedType: &regionalNetwork,
62576269
}, {
62586270
name: "annotation set to REGIONAL",
62596271
service: &v1.Service{

envtest/lb_admission_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ func fakeService(annotations map[string]string, spec *corev1.ServiceSpec) *corev
227227
annotations = make(map[string]string)
228228
}
229229
annotations["kubernetes.digitalocean.com/load-balancer-id"] = lbID
230+
annotations["service.beta.kubernetes.io/do-loadbalancer-type"] = godo.LoadBalancerTypeRegional
230231
annotations["service.beta.kubernetes.io/do-loadbalancer-name"] = serviceName
231232
return &corev1.Service{
232233
ObjectMeta: metav1.ObjectMeta{

0 commit comments

Comments
 (0)