Skip to content

Commit d28a24b

Browse files
authored
Remove enforcement of IPv6 LB as internal (kubernetes#2557)
In OpenStack IPv6 that uses GUAs don't require NAT to access the outside world, so IPv6 can be rechable without Floating IPs, which makes the enforcement of IPv6 LB as internal in CPO not necessary. This commit removes this enforcement, which results in IPv6 load-balancers being allowed to be shared between Services. Also, now it's possible to make the load-balancer use the IPv6 stateful address defined in the loadBalancerIP of the Service.
1 parent b75efdb commit d28a24b

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

pkg/openstack/events.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ const (
2121
eventLBExternalNetworkSearchFailed = "LoadBalancerExternalNetworkSearchFailed"
2222
eventLBSourceRangesIgnored = "LoadBalancerSourceRangesIgnored"
2323
eventLBAZIgnored = "LoadBalancerAvailabilityZonesIgnored"
24+
eventLBFloatingIPSkipped = "LoadBalancerFloatingIPSkipped"
2425
)

pkg/openstack/loadbalancer.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,10 @@ func (lbaas *LbaasV2) createOctaviaLoadBalancer(name, clusterName string, servic
259259

260260
// For external load balancer, the LoadBalancerIP is a public IP address.
261261
loadBalancerIP := service.Spec.LoadBalancerIP
262-
if loadBalancerIP != "" && svcConf.internal {
263-
createOpts.VipAddress = loadBalancerIP
262+
if loadBalancerIP != "" {
263+
if svcConf.internal || (svcConf.preferredIPFamily == corev1.IPv6Protocol) {
264+
createOpts.VipAddress = loadBalancerIP
265+
}
264266
}
265267

266268
if !lbaas.opts.ProviderRequiresSerialAPICalls {
@@ -1315,9 +1317,6 @@ func (lbaas *LbaasV2) checkService(service *corev1.Service, nodes []*corev1.Node
13151317
klog.V(3).InfoS("Enforcing internal LB", "annotation", true, "config", false)
13161318
}
13171319
svcConf.internal = true
1318-
} else if svcConf.preferredIPFamily == corev1.IPv6Protocol {
1319-
// floating IPs are not supported in IPv6 networks
1320-
svcConf.internal = true
13211320
} else {
13221321
svcConf.internal = getBoolFromServiceAnnotation(service, ServiceAnnotationLoadBalancerInternal, lbaas.opts.InternalLB)
13231322
}
@@ -1711,11 +1710,18 @@ func (lbaas *LbaasV2) ensureOctaviaLoadBalancer(ctx context.Context, clusterName
17111710
}
17121711
}
17131712

1714-
addr, err := lbaas.ensureFloatingIP(clusterName, service, loadbalancer, svcConf, isLBOwner)
1715-
if err != nil {
1716-
return nil, err
1713+
addr := loadbalancer.VipAddress
1714+
// IPv6 Load Balancers have no support for Floating IP.
1715+
if netutils.IsIPv6String(addr) {
1716+
msg := "Floating IP not supported for IPv6 Service %s. Using IPv6 address instead %s."
1717+
lbaas.eventRecorder.Eventf(service, corev1.EventTypeWarning, eventLBFloatingIPSkipped, msg, serviceName, addr)
1718+
klog.Infof(msg, serviceName, addr)
1719+
} else {
1720+
addr, err = lbaas.ensureFloatingIP(clusterName, service, loadbalancer, svcConf, isLBOwner)
1721+
if err != nil {
1722+
return nil, err
1723+
}
17171724
}
1718-
17191725
// Add annotation to Service and add LB name to load balancer tags.
17201726
annotationUpdate := map[string]string{
17211727
ServiceAnnotationLoadBalancerID: loadbalancer.ID,

0 commit comments

Comments
 (0)