Skip to content

Commit

Permalink
fix: check svc and endpoint protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed May 13, 2020
1 parent af216cc commit e71b68c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pkg/controller/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controller

import (
"fmt"
kubeovnv1 "github.com/alauda/kube-ovn/pkg/apis/kubeovn/v1"
"strings"

"github.com/alauda/kube-ovn/pkg/util"
Expand Down Expand Up @@ -116,7 +117,13 @@ func (c *Controller) handleUpdateEndpoint(key string) error {
}

for _, port := range svc.Spec.Ports {
vip := fmt.Sprintf("[%s]:%d", clusterIP, port.Port)
var vip string
if util.CheckProtocol(clusterIP) == kubeovnv1.ProtocolIPv6 {
vip = fmt.Sprintf("[%s]:%d", clusterIP, port.Port)
} else {
vip = fmt.Sprintf("%s:%d", clusterIP, port.Port)
}

backends := getServicePortBackends(ep, port, clusterIP)
if port.Protocol == v1.ProtocolTCP {
// for performance reason delete lb with no backends
Expand Down Expand Up @@ -168,7 +175,11 @@ func getServicePortBackends(endpoints *v1.Endpoints, servicePort v1.ServicePort,

for _, address := range subset.Addresses {
if util.CheckProtocol(serviceIP) == util.CheckProtocol(address.IP) {
backends = append(backends, fmt.Sprintf("[%s]:%d", address.IP, targetPort))
if util.CheckProtocol(address.IP) == kubeovnv1.ProtocolIPv6 {
backends = append(backends, fmt.Sprintf("[%s]:%d", address.IP, targetPort))
} else {
backends = append(backends, fmt.Sprintf("%s:%d", address.IP, targetPort))
}
}
}
}
Expand Down

0 comments on commit e71b68c

Please sign in to comment.