Skip to content

Commit

Permalink
fix getting service backends in dual-stack clusters (#2323)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian committed Feb 13, 2023
1 parent 33e6e41 commit fe42367
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/controller/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ func getServicePortBackends(endpoints *v1.Endpoints, pods []*v1.Pod, servicePort

for _, address := range subset.Addresses {
if address.TargetRef == nil || address.TargetRef.Kind != "Pod" {
backends = append(backends, util.JoinHostPort(address.IP, targetPort))
if util.CheckProtocol(address.IP) == protocol {
backends = append(backends, util.JoinHostPort(address.IP, targetPort))
}
continue
}

Expand All @@ -257,7 +259,7 @@ func getServicePortBackends(endpoints *v1.Endpoints, pods []*v1.Pod, servicePort
break
}
}
if ip == "" {
if ip == "" && util.CheckProtocol(address.IP) == protocol {
ip = address.IP
}
if ip != "" {
Expand Down

0 comments on commit fe42367

Please sign in to comment.