Skip to content

Commit f4de94f

Browse files
author
Rahul Sharma
committed
add nb types
1 parent 1b9f2e7 commit f4de94f

File tree

6 files changed

+22
-5
lines changed

6 files changed

+22
-5
lines changed

cloud/annotations/annotations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ const (
3333
AnnLinodeHostUUID = "node.k8s.linode.com/host-uuid"
3434

3535
AnnLinodeNodeIPSharingUpdated = "node.k8s.linode.com/ip-sharing-updated"
36+
37+
AnnLinodeNodeBalancerType = "service.beta.kubernetes.io/linode-nodebalancer-type"
3638
)

cloud/linode/cloud.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ var Options struct {
4646
IpHolderSuffix string
4747
LinodeExternalNetwork *net.IPNet
4848
NodeBalancerTags []string
49+
DefaultNBType string
4950
GlobalStopChannel chan<- struct{}
5051
}
5152

cloud/linode/loadbalancers.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,17 +627,28 @@ func (l *loadbalancers) GetLoadBalancerTags(_ context.Context, clusterName strin
627627
return tags
628628
}
629629

630+
func (l *loadbalancers) GetNodeBalancerType(_ context.Context, service *v1.Service) linodego.NodeBalancerPlanType {
631+
typeStr, ok := service.GetAnnotations()[annotations.AnnLinodeNodeBalancerType]
632+
if ok && linodego.NodeBalancerPlanType(typeStr) == linodego.NBTypePremium {
633+
return linodego.NBTypePremium
634+
}
635+
636+
return linodego.NodeBalancerPlanType(Options.DefaultNBType)
637+
}
638+
630639
func (l *loadbalancers) createNodeBalancer(ctx context.Context, clusterName string, service *v1.Service, configs []*linodego.NodeBalancerConfigCreateOptions) (lb *linodego.NodeBalancer, err error) {
631640
connThrottle := getConnectionThrottle(service)
632641

633642
label := l.GetLoadBalancerName(ctx, clusterName, service)
634643
tags := l.GetLoadBalancerTags(ctx, clusterName, service)
644+
nbType := l.GetNodeBalancerType(ctx, service)
635645
createOpts := linodego.NodeBalancerCreateOptions{
636646
Label: &label,
637647
Region: l.zone,
638648
ClientConnThrottle: &connThrottle,
639649
Configs: configs,
640650
Tags: tags,
651+
Type: nbType,
641652
}
642653

643654
fwid, ok := service.GetAnnotations()[annotations.AnnLinodeCloudFirewallID]

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ require (
6060
github.com/go-openapi/strfmt v0.23.0 // indirect
6161
github.com/go-openapi/swag v0.23.0 // indirect
6262
github.com/go-openapi/validate v0.24.0 // indirect
63-
github.com/go-resty/resty/v2 v2.16.3 // indirect
63+
github.com/go-resty/resty/v2 v2.16.5 // indirect
6464
github.com/gogo/protobuf v1.3.2 // indirect
6565
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
6666
github.com/golang/protobuf v1.5.4 // indirect
@@ -166,3 +166,5 @@ require (
166166
sigs.k8s.io/structured-merge-diff/v4 v4.5.0 // indirect
167167
sigs.k8s.io/yaml v1.4.0 // indirect
168168
)
169+
170+
replace github.com/linode/linodego => github.com/eljohnson92/linodego v0.0.0-20250131225039-9e9e422ab627

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
6161
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6262
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
6363
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
64+
github.com/eljohnson92/linodego v0.0.0-20250131225039-9e9e422ab627 h1:2aCpoTzIKx2h8OTUrswjOL2hII14ppgswt+YqCJR3qU=
65+
github.com/eljohnson92/linodego v0.0.0-20250131225039-9e9e422ab627/go.mod h1:reAU6qPdS59pmxEB4cmaCr0ew19rw9ygz1I05D9Mkyc=
6466
github.com/emicklei/go-restful/v3 v3.12.1 h1:PJMDIM/ak7btuL8Ex0iYET9hxM3CI2sjZtzpL63nKAU=
6567
github.com/emicklei/go-restful/v3 v3.12.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
6668
github.com/envoyproxy/protoc-gen-validate v1.1.0 h1:tntQDh69XqOCOZsDz0lVJQez/2L6Uu2PdjCQwWCJ3bM=
@@ -108,8 +110,8 @@ github.com/go-openapi/validate v0.24.0 h1:LdfDKwNbpB6Vn40xhTdNZAnfLECL81w+VX3Bum
108110
github.com/go-openapi/validate v0.24.0/go.mod h1:iyeX1sEufmv3nPbBdX3ieNviWnOZaJ1+zquzJEf2BAQ=
109111
github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI=
110112
github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow=
111-
github.com/go-resty/resty/v2 v2.16.3 h1:zacNT7lt4b8M/io2Ahj6yPypL7bqx9n1iprfQuodV+E=
112-
github.com/go-resty/resty/v2 v2.16.3/go.mod h1:hkJtXbA2iKHzJheXYvQ8snQES5ZLGKMwQ07xAwp/fiA=
113+
github.com/go-resty/resty/v2 v2.16.5 h1:hBKqmWrr7uRc3euHVqmh1HTHcKn99Smr7o5spptdhTM=
114+
github.com/go-resty/resty/v2 v2.16.5/go.mod h1:hkJtXbA2iKHzJheXYvQ8snQES5ZLGKMwQ07xAwp/fiA=
113115
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
114116
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
115117
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
@@ -199,8 +201,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
199201
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
200202
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
201203
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
202-
github.com/linode/linodego v1.47.0 h1:6MFNCyzWbr8Rhl4r7d5DwZLwxvFIsM4ARH6W0KS/R0U=
203-
github.com/linode/linodego v1.47.0/go.mod h1:vyklQRzZUWhFVBZdYx4dcYJU/gG9yKB9VUcUs6ub0Lk=
204204
github.com/mackerelio/go-osstat v0.2.5 h1:+MqTbZUhoIt4m8qzkVoXUJg1EuifwlAJSk4Yl2GXh+o=
205205
github.com/mackerelio/go-osstat v0.2.5/go.mod h1:atxwWF+POUZcdtR1wnsUcQxTytoHG4uhl2AKKzrOajY=
206206
github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM=

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ func main() {
8787
command.Flags().StringVar(&linode.Options.LoadBalancerType, "load-balancer-type", "nodebalancer", "configures which type of load-balancing to use for LoadBalancer Services (options: nodebalancer, cilium-bgp)")
8888
command.Flags().StringVar(&linode.Options.BGPNodeSelector, "bgp-node-selector", "", "node selector to use to perform shared IP fail-over with BGP (e.g. cilium-bgp-peering=true")
8989
command.Flags().StringVar(&linode.Options.IpHolderSuffix, "ip-holder-suffix", "", "suffix to append to the ip holder name when using shared IP fail-over with BGP (e.g. ip-holder-suffix=my-cluster-name")
90+
command.Flags().StringVar(&linode.Options.DefaultNBType, "default-nb-type", "common", "default type of NodeBalancer to create (options: common, premium)")
9091
command.Flags().StringSliceVar(&linode.Options.NodeBalancerTags, "nodebalancer-tags", []string{}, "Linode tags to apply to all NodeBalancers")
9192

9293
// Set static flags

0 commit comments

Comments
 (0)