Skip to content

Commit

Permalink
initial workaound for IPv6 workload support
Browse files Browse the repository at this point in the history
  • Loading branch information
bonnyr-f5 committed Jan 25, 2022
1 parent 88a255b commit 2ddfa8f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions internal/configs/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,10 @@ func createUpstream(ingEx *IngressEx, name string, backend *networking.IngressBa
}

for _, endp := range endps {
addressport := strings.Split(endp, ":")
pos := strings.LastIndex(endp, ":")
upsServers = append(upsServers, version1.UpstreamServer{
Address: addressport[0],
Port: addressport[1],
Address: endp[:pos],
Port: endp[pos+1:],
MaxFails: cfg.MaxFails,
MaxConns: cfg.MaxConns,
FailTimeout: cfg.FailTimeout,
Expand Down
11 changes: 9 additions & 2 deletions internal/k8s/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2972,7 +2972,7 @@ func getEndpointsBySubselectedPods(targetPort int32, pods []*api_v1.Pod, svcEps
}
for _, address := range subset.Addresses {
if address.IP == pod.Status.PodIP {
addr := fmt.Sprintf("%v:%v", pod.Status.PodIP, targetPort)
addr := ipv6SafeAddrPort(pod.Status.PodIP, targetPort)
ownerType, ownerName := getPodOwnerTypeAndName(pod)
podEnd := podEndpoint{
Address: addr,
Expand All @@ -2991,6 +2991,13 @@ func getEndpointsBySubselectedPods(targetPort int32, pods []*api_v1.Pod, svcEps
return endps
}

func ipv6SafeAddrPort(addr string, port int32) string {
if strings.Count(addr, ":") > 1 && !strings.Contains(addr, "[") {
addr = "[" + addr + "]"
}
return fmt.Sprintf("%v:%v", addr, port) // why %v?
}

func getPodName(pod *api_v1.ObjectReference) string {
if pod != nil {
return pod.Name
Expand Down Expand Up @@ -3103,7 +3110,7 @@ func (lbc *LoadBalancerController) getEndpointsForPort(endps api_v1.Endpoints, b
if port.Port == targetPort {
var endpoints []podEndpoint
for _, address := range subset.Addresses {
addr := fmt.Sprintf("%v:%v", address.IP, port.Port)
addr := ipv6SafeAddrPort(address.IP, port.Port)
podEnd := podEndpoint{
Address: addr,
}
Expand Down

0 comments on commit 2ddfa8f

Please sign in to comment.