diff --git a/cmd/nginx/main.go b/cmd/nginx/main.go index 624f70f73..933a84448 100644 --- a/cmd/nginx/main.go +++ b/cmd/nginx/main.go @@ -83,29 +83,6 @@ func main() { } glog.Infof("validated %v as the default backend", conf.DefaultService) - if conf.PublishService != "" { - ns, name, err := k8s.ParseNameNS(conf.PublishService) - if err != nil { - glog.Fatal(err) - } - - svc, err := kubeClient.CoreV1().Services(ns).Get(name, metav1.GetOptions{}) - if err != nil { - glog.Fatalf("unexpected error getting information about service %v: %v", conf.PublishService, err) - } - - if len(svc.Status.LoadBalancer.Ingress) == 0 { - if len(svc.Spec.ExternalIPs) > 0 { - glog.Infof("service %v validated as assigned with externalIP", conf.PublishService) - } else { - // We could poll here, but we instead just exit and rely on k8s to restart us - glog.Fatalf("service %s does not (yet) have ingress points", conf.PublishService) - } - } else { - glog.Infof("service %v validated as source of Ingress status", conf.PublishService) - } - } - if conf.Namespace != "" { _, err = kubeClient.CoreV1().Namespaces().Get(conf.Namespace, metav1.GetOptions{}) if err != nil { diff --git a/internal/ingress/status/status.go b/internal/ingress/status/status.go index 69bea83ce..1622cbc35 100644 --- a/internal/ingress/status/status.go +++ b/internal/ingress/status/status.go @@ -243,6 +243,11 @@ func (s *statusSync) runningAddresses() ([]string, error) { return nil, err } + if svc.Spec.Type == apiv1.ServiceTypeExternalName { + addrs = append(addrs, svc.Spec.ExternalName) + return addrs, nil + } + for _, ip := range svc.Status.LoadBalancer.Ingress { if ip.IP == "" { addrs = append(addrs, ip.Hostname) diff --git a/internal/k8s/main.go b/internal/k8s/main.go index 6013b5471..556133bf2 100644 --- a/internal/k8s/main.go +++ b/internal/k8s/main.go @@ -45,29 +45,25 @@ func GetNodeIPOrName(kubeClient clientset.Interface, name string, useInternalIP return "" } - ip := "" - - for _, address := range node.Status.Addresses { - if address.Type == apiv1.NodeExternalIP { - if address.Address != "" { - ip = address.Address - break - } - } - } - if useInternalIP { for _, address := range node.Status.Addresses { if address.Type == apiv1.NodeInternalIP { if address.Address != "" { - ip = address.Address - break + return address.Address } } } } - return ip + for _, address := range node.Status.Addresses { + if address.Type == apiv1.NodeExternalIP { + if address.Address != "" { + return address.Address + } + } + } + + return "" } // PodInfo contains runtime information about the pod running the Ingres controller