Always return an IP address (#2065)
This commit is contained in:
parent
42c7111259
commit
d4784cfe59
1 changed files with 14 additions and 10 deletions
|
@ -45,25 +45,29 @@ 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 != "" {
|
||||||
return address.Address
|
ip = address.Address
|
||||||
}
|
break
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for _, address := range node.Status.Addresses {
|
|
||||||
if address.Type == apiv1.NodeExternalIP {
|
|
||||||
if address.Address != "" {
|
|
||||||
return address.Address
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return ip
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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