Merge pull request #2501 from aledbf/refactor-status
Refactor update of status removing initial check for loadbalancer
This commit is contained in:
commit
d234dd4fad
3 changed files with 15 additions and 37 deletions
|
@ -83,29 +83,6 @@ func main() {
|
||||||
}
|
}
|
||||||
glog.Infof("validated %v as the default backend", conf.DefaultService)
|
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 != "" {
|
if conf.Namespace != "" {
|
||||||
_, err = kubeClient.CoreV1().Namespaces().Get(conf.Namespace, metav1.GetOptions{})
|
_, err = kubeClient.CoreV1().Namespaces().Get(conf.Namespace, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -243,6 +243,11 @@ func (s *statusSync) runningAddresses() ([]string, error) {
|
||||||
return nil, err
|
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 {
|
for _, ip := range svc.Status.LoadBalancer.Ingress {
|
||||||
if ip.IP == "" {
|
if ip.IP == "" {
|
||||||
addrs = append(addrs, ip.Hostname)
|
addrs = append(addrs, ip.Hostname)
|
||||||
|
|
|
@ -45,29 +45,25 @@ func GetNodeIPOrName(kubeClient clientset.Interface, name string, useInternalIP
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
ip := ""
|
|
||||||
|
|
||||||
for _, address := range node.Status.Addresses {
|
|
||||||
if address.Type == apiv1.NodeExternalIP {
|
|
||||||
if address.Address != "" {
|
|
||||||
ip = address.Address
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if useInternalIP {
|
if useInternalIP {
|
||||||
for _, address := range node.Status.Addresses {
|
for _, address := range node.Status.Addresses {
|
||||||
if address.Type == apiv1.NodeInternalIP {
|
if address.Type == apiv1.NodeInternalIP {
|
||||||
if address.Address != "" {
|
if address.Address != "" {
|
||||||
ip = address.Address
|
return address.Address
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// PodInfo contains runtime information about the pod running the Ingres controller
|
||||||
|
|
Loading…
Reference in a new issue