|
|
@ -40,6 +40,14 @@ func (b *kubeBuilder) Build(target resolver.Target, cc resolver.ClientConn,
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if svc.Port == 0 {
|
|
|
|
|
|
|
|
endpoints, err := cs.CoreV1().Endpoints(svc.Namespace).Get(context.Background(), svc.Name, v1.GetOptions{})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
svc.Port = int(endpoints.Subsets[0].Ports[0].Port)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
handler := kube.NewEventHandler(func(endpoints []string) {
|
|
|
|
handler := kube.NewEventHandler(func(endpoints []string) {
|
|
|
|
var addrs []resolver.Address
|
|
|
|
var addrs []resolver.Address
|
|
|
|
for _, val := range subset(endpoints, subsetSize) {
|
|
|
|
for _, val := range subset(endpoints, subsetSize) {
|
|
|
@ -64,12 +72,10 @@ func (b *kubeBuilder) Build(target resolver.Target, cc resolver.ClientConn,
|
|
|
|
threading.GoSafe(func() {
|
|
|
|
threading.GoSafe(func() {
|
|
|
|
inf.Start(proc.Done())
|
|
|
|
inf.Start(proc.Done())
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
endpoints, err := cs.CoreV1().Endpoints(svc.Namespace).Get(context.Background(), svc.Name, v1.GetOptions{})
|
|
|
|
endpoints, err := cs.CoreV1().Endpoints(svc.Namespace).Get(context.Background(), svc.Name, v1.GetOptions{})
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
handler.Update(endpoints)
|
|
|
|
handler.Update(endpoints)
|
|
|
|
|
|
|
|
|
|
|
|
return &nopResolver{cc: cc}, nil
|
|
|
|
return &nopResolver{cc: cc}, nil
|
|
|
|