Now it iterates over all endpoints in k8s cluster. And get its service and do some kind of compare&conversion work.
In cluster with massive of services and endpoints, pilot could be very slow .
We should get the services by the way kubernetes endpoint_controller does: using the svc selector to match pod labels.
func (s *serviceLister) GetPodServices(pod *v1.Pod) ([]*v1.Service, error) {
allServices, err := s.Services(pod.Namespace).List(labels.Everything())
if err != nil {
return nil, err
}
var services []*v1.Service
for i := range allServices {
service := allServices[i]
if service.Spec.Selector == nil {
// services with nil selectors match nothing, not everything.
continue
}
selector := labels.Set(service.Spec.Selector).AsSelectorPreValidated()
if selector.Matches(labels.Set(pod.Labels)) {
services = append(services, service)
}
}
return services, nil
}
GetProxyServiceInstances
https://github.com/istio/istio/blob/master/pilot/pkg/serviceregistry/kube/controller.go#L413-L471
Now it iterates over all endpoints in k8s cluster. And get its service and do some kind of compare&conversion work.
In cluster with massive of services and endpoints, pilot could be very slow .
We should get the services by the way kubernetes endpoint_controller does: using the svc selector to match pod labels.