only range over pods for services with a selector
@@ -97,6 +97,7 @@ func upstreamsForService(svc *kubev1.Service, pods []*kubev1.Pod, writeNamespace
uniqueLabelSets := []map[string]string{
svc.Spec.Selector,
}
+ if len(svc.Spec.Selector) > 0 {
for _, pod := range pods {
if pod.Namespace != svc.Namespace {
continue
@@ -122,6 +123,8 @@ func upstreamsForService(svc *kubev1.Service, pods []*kubev1.Pod, writeNamespace
}
}
+ }
+
for _, extendedLabels := range uniqueLabelSets {
for _, port := range svc.Spec.Ports {
upstreams = append(upstreams, createUpstream(writeNamespace, svc, port, extendedLabels))
