Skip to content

Commit

Permalink
Merge pull request #2183 from panslava/fix-ipv6-static-ips
Browse files Browse the repository at this point in the history
Add /96 suffix to static addresses for IPv6 external forwarding rules
  • Loading branch information
k8s-ci-robot authored Jun 30, 2023
2 parents 6fc964d + 547e219 commit 7b46676
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions pkg/loadbalancers/forwarding_rules_ipv6.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (

const (
IPVersionIPv6 = "IPV6"
prefix96range = "/96"
)

func (l4 *L4) ensureIPv6ForwardingRule(bsLink string, options gce.ILBOptions, existingIPv6FwdRule *composite.ForwardingRule, ipv6AddressToUse string) (*composite.ForwardingRule, error) {
Expand Down Expand Up @@ -210,6 +211,14 @@ func (l4netlb *L4NetLB) buildExpectedIPv6ForwardingRule(bsLink, ipv6AddressToUse
return nil, fmt.Errorf("failed to compute description for forwarding rule %s, err: %w", frName, err)
}

// ipv6AddressToUse will be returned from address manager without /96 prefix.
// for creating external IPv6 forwarding rule, address has to be specified with /96 prefix, or API will return error.
// This applies only to IPv6 External Forwarding rules,
// there is no such requirement for internal IPv6 forwarding rules.
if ipv6AddressToUse != "" && !strings.HasSuffix(ipv6AddressToUse, prefix96range) {
ipv6AddressToUse += prefix96range
}

svcPorts := l4netlb.Service.Spec.Ports
portRange, protocol := utils.MinMaxPortRangeAndProtocol(svcPorts)
fr := &composite.ForwardingRule{
Expand Down
4 changes: 2 additions & 2 deletions pkg/loadbalancers/l4netlbipv6.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ func (l4netlb *L4NetLB) ensureIPv6NodesFirewall(ipAddress string, nodeNames []st
portRanges := utils.GetServicePortRanges(svcPorts)
protocol := utils.GetProtocol(svcPorts)

klog.V(2).Infof("Ensuring IPv6 nodes firewall %s for L4 ILB Service %s/%s, ipAddress: %s, protocol: %s, len(nodeNames): %v, portRanges: %v", firewallName, l4netlb.Service.Namespace, l4netlb.Service.Name, ipAddress, protocol, len(nodeNames), portRanges)
klog.V(2).Infof("Ensuring IPv6 nodes firewall %s for L4 NetLB Service %s/%s, ipAddress: %s, protocol: %s, len(nodeNames): %v, portRanges: %v", firewallName, l4netlb.Service.Namespace, l4netlb.Service.Name, ipAddress, protocol, len(nodeNames), portRanges)
defer func() {
klog.V(2).Infof("Finished ensuring IPv6 nodes firewall %s for L4 ILB Service %s/%s, time taken: %v", l4netlb.Service.Namespace, l4netlb.Service.Name, firewallName, time.Since(start))
klog.V(2).Infof("Finished ensuring IPv6 nodes firewall %s for L4 NetLB Service %s/%s, time taken: %v", l4netlb.Service.Namespace, l4netlb.Service.Name, firewallName, time.Since(start))
}()

// ensure firewalls
Expand Down

0 comments on commit 7b46676

Please sign in to comment.