@@ -57,6 +57,7 @@ type LoadBalancerAPI interface {
5757 ListLBs (req * scwlb.ZonedAPIListLBsRequest , opts ... scw.RequestOption ) (* scwlb.ListLBsResponse , error )
5858 GetLB (req * scwlb.ZonedAPIGetLBRequest , opts ... scw.RequestOption ) (* scwlb.LB , error )
5959 CreateLB (req * scwlb.ZonedAPICreateLBRequest , opts ... scw.RequestOption ) (* scwlb.LB , error )
60+ UpdateLB (req * scwlb.ZonedAPIUpdateLBRequest , opts ... scw.RequestOption ) (* scwlb.LB , error )
6061 DeleteLB (req * scwlb.ZonedAPIDeleteLBRequest , opts ... scw.RequestOption ) error
6162 MigrateLB (req * scwlb.ZonedAPIMigrateLBRequest , opts ... scw.RequestOption ) (* scwlb.LB , error )
6263 ListIPs (req * scwlb.ZonedAPIListIPsRequest , opts ... scw.RequestOption ) (* scwlb.ListIPsResponse , error )
@@ -469,6 +470,12 @@ func (l *loadbalancers) createLoadBalancer(ctx context.Context, clusterName stri
469470 return nil , fmt .Errorf ("invalid value for annotation %s: expected boolean" , serviceAnnotationLoadBalancerPrivate )
470471 }
471472
473+ sslCompatibilityLevel , err := getSSLCompatibilityLevel (service )
474+ if err != nil {
475+ klog .Errorf ("error getting SSL compatibility level for service %s(%s): %v" , service .Name , service .UID , err )
476+ return nil , fmt .Errorf ("error getting SSL compatibility level for service %s(%s): %v" , service .Name , service .UID , err )
477+ }
478+
472479 // Attach specific IP if set
473480 var ipIDs []string
474481 if ! lbPrivate {
@@ -503,7 +510,8 @@ func (l *loadbalancers) createLoadBalancer(ctx context.Context, clusterName stri
503510 Type : lbType ,
504511 // We must only assign a flexible IP if LB is public AND no IP ID is provided.
505512 // If IP IDs are provided, there must be at least one IPv4.
506- AssignFlexibleIP : scw .BoolPtr (! lbPrivate && len (ipIDs ) == 0 ),
513+ AssignFlexibleIP : scw .BoolPtr (! lbPrivate && len (ipIDs ) == 0 ),
514+ SslCompatibilityLevel : sslCompatibilityLevel ,
507515 }
508516 lb , err := l .api .CreateLB (& request )
509517 if err != nil {
@@ -780,6 +788,27 @@ func (l *loadbalancers) updateLoadBalancer(ctx context.Context, loadbalancer *sc
780788 return fmt .Errorf ("error updating load balancer %s: %v" , loadbalancer .ID , err )
781789 }
782790 }
791+
792+ // Update SSL compatibility level if needed
793+ sslCompatibilityLevel , err := getSSLCompatibilityLevel (service )
794+ if err != nil {
795+ klog .Errorf ("error getting SSL compatibility level on the service %s for load balancer %s: %v" , service .Name , loadbalancer .ID , err )
796+ return fmt .Errorf ("error getting SSL compatibility level on the service %s for load balancer %s: %v" , service .Name , loadbalancer .ID , err )
797+ }
798+ if loadbalancer .SslCompatibilityLevel != sslCompatibilityLevel {
799+ _ , err := l .api .UpdateLB (& scwlb.ZonedAPIUpdateLBRequest {
800+ Zone : loadbalancer .Zone ,
801+ LBID : loadbalancer .ID ,
802+ Name : loadbalancer .Name ,
803+ Description : loadbalancer .Description ,
804+ Tags : loadbalancer .Tags ,
805+ SslCompatibilityLevel : sslCompatibilityLevel ,
806+ })
807+ if err != nil {
808+ klog .Errorf ("error updating load balancer %s: %v" , loadbalancer .ID , err )
809+ return fmt .Errorf ("error updating load balancer %s: %v" , loadbalancer .ID , err )
810+ }
811+ }
783812 }
784813
785814 return nil
0 commit comments