diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index a8521863bfb..e39ebf09132 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -557,6 +557,14 @@ func LoadConfig() (config *restclient.Config, err error) { } return nil, err } + // In case Host is not set in TestContext, sets it as + // CurrentContext Server for k8s API client to connect to. + if TestContext.Host == "" && c.Clusters != nil { + currentContext, ok := c.Clusters[c.CurrentContext] + if ok { + TestContext.Host = currentContext.Server + } + } return clientcmd.NewDefaultClientConfig(*c, &clientcmd.ConfigOverrides{ClusterInfo: clientcmdapi.Cluster{Server: TestContext.Host}}).ClientConfig() }