Skip to content

Commit

Permalink
Ensure an IP address is registered for the virtual node
Browse files Browse the repository at this point in the history
  • Loading branch information
ldx committed Feb 6, 2020
1 parent 61e1213 commit 87548f2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cmd/virtual-kubelet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 87548f2

Please sign in to comment.