diff --git a/cmd/virtual-kubelet/main.go b/cmd/virtual-kubelet/main.go index a89061dd..3827d3a5 100644 --- a/cmd/virtual-kubelet/main.go +++ b/cmd/virtual-kubelet/main.go @@ -21,6 +21,7 @@ import ( "github.com/elotl/cloud-instance-provider/pkg/klog" "github.com/elotl/cloud-instance-provider/pkg/server" + "github.com/elotl/cloud-instance-provider/pkg/util/habitat" cli "github.com/virtual-kubelet/node-cli" opencensuscli "github.com/virtual-kubelet/node-cli/opencensus" "github.com/virtual-kubelet/node-cli/opts" @@ -63,10 +64,21 @@ func main() { cli.WithCLIVersion(buildVersion, buildTime), cli.WithProvider("cloud-instance-provider", func(cfg provider.InitConfig) (provider.Provider, error) { + internalIP := cfg.InternalIP + if internalIP == "" { + internalIP = habitat.GetMyIP() + if internalIP == "" { + ips := habitat.GetIPAddresses() + if len(ips) > 0 { + internalIP = ips[0] + } + } + } + log.G(ctx).Infof("node internal IP address: %q", internalIP) return server.NewInstanceProvider( cfg.ConfigPath, cfg.NodeName, - cfg.InternalIP, + internalIP, cfg.DaemonPort, serverConfig.DebugServer, cfg.ResourceManager,