Skip to content

Commit b93deac

Browse files
committed
ignore LoadBalancer Service if loadBalancerClass is set to cilium
1 parent 3332b2a commit b93deac

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

cloud/linode/loadbalancers.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ func (l *loadbalancers) EnsureLoadBalancer(ctx context.Context, clusterName stri
185185
sentry.SetTag(ctx, "cluster_name", clusterName)
186186
sentry.SetTag(ctx, "service", service.Name)
187187

188+
if *service.Spec.LoadBalancerClass == "io.cilium/bgp-control-plane" {
189+
klog.Infof("Skipping NodeBalancer creation for Cilium LoadBalancerClass")
190+
return lbStatus, err
191+
}
192+
188193
var nb *linodego.NodeBalancer
189194
serviceNn := getServiceNn(service)
190195

cloud/linode/loadbalancers_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ func TestCCMLoadBalancers(t *testing.T) {
122122
name: "Get Load Balancer",
123123
f: testGetLoadBalancer,
124124
},
125+
{
126+
name: "Create Load Balancer With loadBalancerClass",
127+
f: testCreateNodeBalancerWithLBClass,
128+
},
125129
{
126130
name: "Create Load Balancer Without Firewall",
127131
f: testCreateNodeBalancerWithOutFirewall,
@@ -270,6 +274,48 @@ func stubService(fake *fake.Clientset, service *v1.Service) {
270274
_, _ = fake.CoreV1().Services("").Create(context.TODO(), service, metav1.CreateOptions{})
271275
}
272276

277+
func testCreateNodeBalancerWithLBClass(t *testing.T, client *linodego.Client, _ *fakeAPI) {
278+
lbClass := "io.cilium/bgp-control-plane"
279+
svc := &v1.Service{
280+
ObjectMeta: metav1.ObjectMeta{
281+
Name: randString(),
282+
UID: "foobar123",
283+
Annotations: map[string]string{
284+
annotations.AnnLinodeThrottle: "15",
285+
annotations.AnnLinodeLoadBalancerTags: "fake,test,yolo",
286+
},
287+
},
288+
Spec: v1.ServiceSpec{
289+
LoadBalancerClass: &lbClass,
290+
Ports: []v1.ServicePort{
291+
{
292+
Name: randString(),
293+
Protocol: "TCP",
294+
Port: int32(80),
295+
NodePort: int32(30000),
296+
},
297+
{
298+
Name: randString(),
299+
Protocol: "TCP",
300+
Port: int32(8080),
301+
NodePort: int32(30001),
302+
},
303+
},
304+
},
305+
}
306+
lb := &loadbalancers{client, "us-west", nil}
307+
nodes := []*v1.Node{
308+
{ObjectMeta: metav1.ObjectMeta{Name: "node-1"}},
309+
}
310+
nb, err := lb.EnsureLoadBalancer(context.TODO(), "linodelb", svc, nodes)
311+
if err != nil {
312+
t.Fatalf("expected a nil error, got %v", err)
313+
}
314+
if nb != nil {
315+
t.Fatalf("expected a nil nb, got %v", nb)
316+
}
317+
}
318+
273319
func testCreateNodeBalancer(t *testing.T, client *linodego.Client, _ *fakeAPI, annMap map[string]string) error {
274320
svc := &v1.Service{
275321
ObjectMeta: metav1.ObjectMeta{

cloud/linode/service_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (s *serviceController) Run(stopCh <-chan struct{}) {
4040
return
4141
}
4242

43-
if service.Spec.Type != "LoadBalancer" {
43+
if service.Spec.Type != "LoadBalancer" || *service.Spec.LoadBalancerClass == "io.cilium/bgp-control-plane" {
4444
return
4545
}
4646

0 commit comments

Comments
 (0)