diff --git a/internal/k8s/main.go b/internal/k8s/main.go index dcb887c0a..6013b5471 100644 --- a/internal/k8s/main.go +++ b/internal/k8s/main.go @@ -45,25 +45,29 @@ 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 != "" { - return address.Address - } - } - } - } else { - for _, address := range node.Status.Addresses { - if address.Type == apiv1.NodeExternalIP { - if address.Address != "" { - return address.Address + ip = address.Address + break } } } } - return "" + return ip } // PodInfo contains runtime information about the pod running the Ingres controller