@@ -144,8 +144,9 @@ const (
144144)
145145
146146type loadbalancers struct {
147- api LoadBalancerAPI
148- client * client // for patcher
147+ api LoadBalancerAPI
148+ client * client // for patcher
149+ defaultLBType string
149150}
150151
151152type LoadBalancerAPI interface {
@@ -171,10 +172,15 @@ type LoadBalancerAPI interface {
171172 UpdateACL (req * scwlb.UpdateACLRequest , opts ... scw.RequestOption ) (* scwlb.ACL , error )
172173}
173174
174- func newLoadbalancers (client * client ) * loadbalancers {
175+ func newLoadbalancers (client * client , defaultLBType string ) * loadbalancers {
176+ lbType := "lb-s"
177+ if defaultLBType != "" {
178+ lbType = strings .ToLower (defaultLBType )
179+ }
175180 return & loadbalancers {
176- api : scwlb .NewAPI (client .scaleway ),
177- client : client ,
181+ api : scwlb .NewAPI (client .scaleway ),
182+ client : client ,
183+ defaultLBType : lbType ,
178184 }
179185}
180186
@@ -477,12 +483,17 @@ func (l *loadbalancers) createLoadBalancer(ctx context.Context, clusterName stri
477483 tags = append (tags , "managed-by-scaleway-cloud-controller-manager" )
478484 lbName := l .GetLoadBalancerName (ctx , clusterName , service )
479485
486+ lbType := getLoadBalancerType (service )
487+ if lbType != "" {
488+ lbType = l .defaultLBType
489+ }
490+
480491 request := scwlb.CreateLBRequest {
481492 Name : lbName ,
482493 Description : "kubernetes service " + service .Name ,
483494 Tags : tags ,
484495 IPID : ipID ,
485- Type : getLoadBalancerType ( service ) ,
496+ Type : lbType ,
486497 }
487498
488499 lb , err := l .api .CreateLB (& request )
@@ -773,7 +784,7 @@ func (l *loadbalancers) updateLoadBalancer(ctx context.Context, loadbalancer *sc
773784 }
774785
775786 loadBalancerType := getLoadBalancerType (service )
776- if loadBalancerType != "" && strings .ToLower (loadbalancer .Type ) != strings . ToLower ( loadBalancerType ) {
787+ if loadBalancerType != "" && strings .ToLower (loadbalancer .Type ) != loadBalancerType {
777788 _ , err := l .api .MigrateLB (& scwlb.MigrateLBRequest {
778789 LBID : loadbalancer .ID ,
779790 Type : loadBalancerType ,
@@ -1197,7 +1208,7 @@ func isPortInRange(r string, p int32) (bool, error) {
11971208}
11981209
11991210func getLoadBalancerType (service * v1.Service ) string {
1200- return service .Annotations [serviceAnnotationLoadBalancerType ]
1211+ return strings . ToLower ( service .Annotations [serviceAnnotationLoadBalancerType ])
12011212}
12021213
12031214func getProxyProtocol (service * v1.Service , nodePort int32 ) (scwlb.ProxyProtocol , error ) {
0 commit comments