Commit 380da817 authored by Geoff Simmons's avatar Geoff Simmons

Service.status.loadBalancer may have info for Ingress.status.loadBalancer.

Also, the Service info sources for Ingress loadBalancer status depend
on the Service type, mostly following the nginx ingress implementation.
parent 9cb0fc5d
......@@ -949,27 +949,40 @@ func (worker *NamespaceWorker) updateIngStatus(
if !reflect.DeepEqual(svc.Spec.Selector, admSvc.Spec.Selector) {
continue
}
if svc.Spec.Type != api_v1.ServiceTypeClusterIP &&
svc.Spec.Type != api_v1.ServiceTypeNodePort &&
svc.Spec.Type != api_v1.ServiceTypeLoadBalancer {
switch svc.Spec.Type {
case api_v1.ServiceTypeClusterIP:
if svc.Spec.ClusterIP != "" {
ips[svc.Spec.ClusterIP] = struct{}{}
}
case api_v1.ServiceTypeNodePort:
for _, extIP := range svc.Spec.ExternalIPs {
ips[extIP] = struct{}{}
}
if svc.Spec.ClusterIP != "" {
ips[svc.Spec.ClusterIP] = struct{}{}
}
case api_v1.ServiceTypeLoadBalancer:
for _, ing := range svc.Status.LoadBalancer.Ingress {
if ing.IP != "" {
ips[ing.IP] = struct{}{}
}
if ing.Hostname != "" {
hosts[ing.Hostname] = struct{}{}
}
}
if svc.Spec.LoadBalancerIP != "" {
ips[svc.Spec.LoadBalancerIP] = struct{}{}
}
case api_v1.ServiceTypeExternalName:
if svc.Spec.ExternalName != "" {
hosts[svc.Spec.ExternalName] = struct{}{}
}
default:
worker.log.Warnf("Service %s/%s has label %s=%s but "+
"type %s, not adding to status.loadBalancer "+
"for Ingress(es): %v", svc.Namespace, svc.Name,
vikingPubSvcKey, vikingPubSvcVal, svc.Spec.Type,
ings)
continue
}
if svc.Spec.ExternalName != "" {
hosts[svc.Spec.ExternalName] = struct{}{}
}
if svc.Spec.LoadBalancerIP != "" {
ips[svc.Spec.LoadBalancerIP] = struct{}{}
}
for _, extIP := range svc.Spec.ExternalIPs {
ips[extIP] = struct{}{}
}
if svc.Spec.ClusterIP != "" {
ips[svc.Spec.ClusterIP] = struct{}{}
}
}
if len(ips)+len(hosts) == 0 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment