|
|
@ -150,35 +150,23 @@ func (s *Server) listenersFromSnapshotConnectProxy(cInfo connectionInfo, cfgSnap
|
|
|
|
uniqueAddrs := make(map[string]struct{})
|
|
|
|
uniqueAddrs := make(map[string]struct{})
|
|
|
|
|
|
|
|
|
|
|
|
for _, t := range chain.Targets {
|
|
|
|
for _, t := range chain.Targets {
|
|
|
|
var k8sNamespace string
|
|
|
|
// Store all the possible IP addresses that might be used to dial this endpoint
|
|
|
|
|
|
|
|
|
|
|
|
// Store all the IP addresses per unique port
|
|
|
|
|
|
|
|
for _, e := range endpoints[t.ID] {
|
|
|
|
for _, e := range endpoints[t.ID] {
|
|
|
|
addr, _ := e.BestAddress(false)
|
|
|
|
if e.Service.Address != "" {
|
|
|
|
|
|
|
|
uniqueAddrs[e.Service.Address] = struct{}{}
|
|
|
|
if _, ok := uniqueAddrs[addr]; !ok {
|
|
|
|
|
|
|
|
uniqueAddrs[addr] = struct{}{}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if e.Node.Address != "" {
|
|
|
|
// The k8s namespace should be the same for all instances, so pick any
|
|
|
|
uniqueAddrs[e.Node.Address] = struct{}{}
|
|
|
|
if ns, ok := e.Service.Meta["k8s-namespace"]; ok {
|
|
|
|
|
|
|
|
k8sNamespace = ns
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO (freddy) hack to remove for beta: for every potential discovery chain target, resolve the k8s ClusterIP
|
|
|
|
for _, tagged := range e.Node.TaggedAddresses {
|
|
|
|
// since it's not stored in Consul's catalog (yet)
|
|
|
|
if tagged != "" {
|
|
|
|
if k8sNamespace != "" {
|
|
|
|
uniqueAddrs[tagged] = struct{}{}
|
|
|
|
host := fmt.Sprintf("%s.%s.svc.cluster.local", t.Service, k8sNamespace)
|
|
|
|
}
|
|
|
|
resolved, err := net.LookupHost(host)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
// We still have the Pod ips in the catalog, so don't hard-fail on errors
|
|
|
|
|
|
|
|
s.Logger.Warn("failed to resolve", "host", host, "error", err)
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, addr := range resolved {
|
|
|
|
for _, tagged := range e.Service.TaggedAddresses {
|
|
|
|
if _, ok := uniqueAddrs[addr]; !ok {
|
|
|
|
if tagged.Address != "" {
|
|
|
|
uniqueAddrs[addr] = struct{}{}
|
|
|
|
uniqueAddrs[tagged.Address] = struct{}{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|