@@ -1278,19 +1278,6 @@ func (lbaas *LbaasV2) checkServiceUpdate(ctx context.Context, service *corev1.Se
1278
1278
svcConf .preferredIPFamily = service .Spec .IPFamilies [0 ]
1279
1279
}
1280
1280
1281
- svcConf .lbID = getStringFromServiceAnnotation (service , ServiceAnnotationLoadBalancerID , "" )
1282
- svcConf .supportLBTags = openstackutil .IsOctaviaFeatureSupported (lbaas .lb , openstackutil .OctaviaFeatureTags , lbaas .opts .LBProvider )
1283
-
1284
- // Get service node-selector annotations
1285
- svcConf .nodeSelectors = getKeyValueFromServiceAnnotation (service , ServiceAnnotationLoadBalancerNodeSelector , lbaas .opts .NodeSelector )
1286
- for key , value := range svcConf .nodeSelectors {
1287
- if value == "" {
1288
- klog .V (3 ).InfoS ("Target node label %s key is set to LoadBalancer service %s" , key , serviceName )
1289
- } else {
1290
- klog .V (3 ).InfoS ("Target node label %s=%s is set to LoadBalancer service %s" , key , value , serviceName )
1291
- }
1292
- }
1293
-
1294
1281
// Find subnet ID for creating members
1295
1282
memberSubnetID , err := lbaas .getMemberSubnetID (service )
1296
1283
if err != nil {
@@ -1322,25 +1309,7 @@ func (lbaas *LbaasV2) checkServiceUpdate(ctx context.Context, service *corev1.Se
1322
1309
}
1323
1310
}
1324
1311
}
1325
-
1326
- // This affects the protocol of listener and pool
1327
- keepClientIP := getBoolFromServiceAnnotation (service , ServiceAnnotationLoadBalancerXForwardedFor , false )
1328
- svcConf .proxyProtocolVersion = getProxyProtocolFromServiceAnnotation (service )
1329
- if svcConf .proxyProtocolVersion != nil && keepClientIP {
1330
- return fmt .Errorf ("annotation %s and %s cannot be used together" , ServiceAnnotationLoadBalancerProxyEnabled , ServiceAnnotationLoadBalancerXForwardedFor )
1331
- }
1332
- svcConf .keepClientIP = keepClientIP
1333
-
1334
- svcConf .tlsContainerRef = getStringFromServiceAnnotation (service , ServiceAnnotationTlsContainerRef , lbaas .opts .TlsContainerRef )
1335
- svcConf .enableMonitor = getBoolFromServiceAnnotation (service , ServiceAnnotationLoadBalancerEnableHealthMonitor , lbaas .opts .CreateMonitor )
1336
- if svcConf .enableMonitor && service .Spec .ExternalTrafficPolicy == corev1 .ServiceExternalTrafficPolicyTypeLocal && service .Spec .HealthCheckNodePort > 0 {
1337
- svcConf .healthCheckNodePort = int (service .Spec .HealthCheckNodePort )
1338
- }
1339
- svcConf .healthMonitorDelay = getIntFromServiceAnnotation (service , ServiceAnnotationLoadBalancerHealthMonitorDelay , int (lbaas .opts .MonitorDelay .Duration .Seconds ()))
1340
- svcConf .healthMonitorTimeout = getIntFromServiceAnnotation (service , ServiceAnnotationLoadBalancerHealthMonitorTimeout , int (lbaas .opts .MonitorTimeout .Duration .Seconds ()))
1341
- svcConf .healthMonitorMaxRetries = getIntFromServiceAnnotation (service , ServiceAnnotationLoadBalancerHealthMonitorMaxRetries , int (lbaas .opts .MonitorMaxRetries ))
1342
- svcConf .healthMonitorMaxRetriesDown = getIntFromServiceAnnotation (service , ServiceAnnotationLoadBalancerHealthMonitorMaxRetriesDown , int (lbaas .opts .MonitorMaxRetriesDown ))
1343
- return nil
1312
+ return lbaas .makeSvcConf (serviceName , service , svcConf )
1344
1313
}
1345
1314
1346
1315
func (lbaas * LbaasV2 ) checkServiceDelete (service * corev1.Service , svcConf * serviceConfig ) error {
@@ -1372,19 +1341,6 @@ func (lbaas *LbaasV2) checkService(ctx context.Context, service *corev1.Service,
1372
1341
svcConf .preferredIPFamily = service .Spec .IPFamilies [0 ]
1373
1342
}
1374
1343
1375
- svcConf .lbID = getStringFromServiceAnnotation (service , ServiceAnnotationLoadBalancerID , "" )
1376
- svcConf .supportLBTags = openstackutil .IsOctaviaFeatureSupported (lbaas .lb , openstackutil .OctaviaFeatureTags , lbaas .opts .LBProvider )
1377
-
1378
- // Get service node-selector annotations
1379
- svcConf .nodeSelectors = getKeyValueFromServiceAnnotation (service , ServiceAnnotationLoadBalancerNodeSelector , lbaas .opts .NodeSelector )
1380
- for key , value := range svcConf .nodeSelectors {
1381
- if value == "" {
1382
- klog .V (3 ).InfoS ("Target node label %s key is set to LoadBalancer service %s" , key , serviceName )
1383
- } else {
1384
- klog .V (3 ).InfoS ("Target node label %s=%s is set to LoadBalancer service %s" , key , value , serviceName )
1385
- }
1386
- }
1387
-
1388
1344
// If in the config file internal-lb=true, user is not allowed to create external service.
1389
1345
if lbaas .opts .InternalLB {
1390
1346
if ! getBoolFromServiceAnnotation (service , ServiceAnnotationLoadBalancerInternal , false ) {
@@ -1429,8 +1385,6 @@ func (lbaas *LbaasV2) checkService(ctx context.Context, service *corev1.Service,
1429
1385
}
1430
1386
}
1431
1387
1432
- svcConf .connLimit = getIntFromServiceAnnotation (service , ServiceAnnotationLoadBalancerConnLimit , - 1 )
1433
-
1434
1388
lbNetworkID , err := lbaas .getNetworkID (service , svcConf )
1435
1389
if err != nil {
1436
1390
return fmt .Errorf ("failed to get network id to create load balancer for service %s: %v" , serviceName , err )
@@ -1549,6 +1503,23 @@ func (lbaas *LbaasV2) checkService(ctx context.Context, service *corev1.Service,
1549
1503
} else {
1550
1504
klog .V (4 ).Infof ("Ensure an internal loadbalancer service." )
1551
1505
}
1506
+ return lbaas .makeSvcConf (serviceName , service , svcConf )
1507
+ }
1508
+
1509
+ func (lbaas * LbaasV2 ) makeSvcConf (serviceName string , service * corev1.Service , svcConf * serviceConfig ) error {
1510
+ svcConf .connLimit = getIntFromServiceAnnotation (service , ServiceAnnotationLoadBalancerConnLimit , - 1 )
1511
+ svcConf .lbID = getStringFromServiceAnnotation (service , ServiceAnnotationLoadBalancerID , "" )
1512
+ svcConf .supportLBTags = openstackutil .IsOctaviaFeatureSupported (lbaas .lb , openstackutil .OctaviaFeatureTags , lbaas .opts .LBProvider )
1513
+
1514
+ // Get service node-selector annotations
1515
+ svcConf .nodeSelectors = getKeyValueFromServiceAnnotation (service , ServiceAnnotationLoadBalancerNodeSelector , lbaas .opts .NodeSelector )
1516
+ for key , value := range svcConf .nodeSelectors {
1517
+ if value == "" {
1518
+ klog .V (3 ).InfoS ("Target node label %s key is set to LoadBalancer service %s" , key , serviceName )
1519
+ } else {
1520
+ klog .V (3 ).InfoS ("Target node label %s=%s is set to LoadBalancer service %s" , key , value , serviceName )
1521
+ }
1522
+ }
1552
1523
1553
1524
keepClientIP := getBoolFromServiceAnnotation (service , ServiceAnnotationLoadBalancerXForwardedFor , false )
1554
1525
svcConf .proxyProtocolVersion = getProxyProtocolFromServiceAnnotation (service )
@@ -1593,6 +1564,7 @@ func (lbaas *LbaasV2) checkService(ctx context.Context, service *corev1.Service,
1593
1564
klog .Warningf (msg , serviceName )
1594
1565
}
1595
1566
1567
+ svcConf .tlsContainerRef = getStringFromServiceAnnotation (service , ServiceAnnotationTlsContainerRef , lbaas .opts .TlsContainerRef )
1596
1568
svcConf .enableMonitor = getBoolFromServiceAnnotation (service , ServiceAnnotationLoadBalancerEnableHealthMonitor , lbaas .opts .CreateMonitor )
1597
1569
if svcConf .enableMonitor && service .Spec .ExternalTrafficPolicy == corev1 .ServiceExternalTrafficPolicyTypeLocal && service .Spec .HealthCheckNodePort > 0 {
1598
1570
svcConf .healthCheckNodePort = int (service .Spec .HealthCheckNodePort )
0 commit comments