Skip to content

Commit

Permalink
Issue #2416: Added UUID to hyperkit driver section in minikube config…
Browse files Browse the repository at this point in the history
…uration to be able to regenerate the same mac address for the machine after restarts to give DHCP a change of assigning the previously used IP address.
  • Loading branch information
bpasson authored and dlorenc committed Jan 11, 2018
1 parent e278d62 commit cebd704
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const (
mountString = "mount-string"
disableDriverMounts = "disable-driver-mounts"
cacheImages = "cache-images"
uuid = "uuid"
)

var (
Expand Down Expand Up @@ -143,6 +144,7 @@ func runStart(cmd *cobra.Command, args []string) {
KvmNetwork: viper.GetString(kvmNetwork),
Downloader: pkgutil.DefaultDownloader{},
DisableDriverMounts: viper.GetBool(disableDriverMounts),
UUID: viper.GetString(uuid),
}

fmt.Printf("Starting local Kubernetes %s cluster...\n", viper.GetString(kubernetesVersion))
Expand Down
7 changes: 3 additions & 4 deletions pkg/drivers/hyperkit/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/docker/machine/libmachine/state"
nfsexports "github.com/johanneswuerbach/nfsexports"
hyperkit "github.com/moby/hyperkit/go"
"github.com/pborman/uuid"
"github.com/pkg/errors"
pkgdrivers "k8s.io/minikube/pkg/drivers"
commonutil "k8s.io/minikube/pkg/util"
Expand All @@ -59,6 +58,7 @@ type Driver struct {
Cmdline string
NFSShares []string
NFSSharesRoot string
UUID string
}

func NewDriver(hostName, storePath string) *Driver {
Expand Down Expand Up @@ -177,10 +177,9 @@ func (d *Driver) Start() error {
h.Console = hyperkit.ConsoleFile
h.CPUs = d.CPU
h.Memory = d.Memory
h.UUID = d.UUID

// Set UUID
h.UUID = uuid.NewUUID().String()
log.Infof("Generated UUID %s", h.UUID)
log.Infof("Using UUID %s", h.UUID)
mac, err := GetMACAddressFromUUID(h.UUID)
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions pkg/minikube/cluster/cluster_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/docker/machine/drivers/vmwarefusion"
"github.com/docker/machine/libmachine/drivers"
"github.com/pborman/uuid"
"k8s.io/minikube/pkg/drivers/hyperkit"
cfg "k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
Expand Down Expand Up @@ -71,6 +72,7 @@ func createHyperkitHost(config MachineConfig) *hyperkit.Driver {
CPU: config.CPUs,
NFSShares: config.NFSShare,
NFSSharesRoot: config.NFSSharesRoot,
UUID: uuid.NewUUID().String(),
Cmdline: "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=" + cfg.GetMachineName(),
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/minikube/cluster/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type MachineConfig struct {
DisableDriverMounts bool // Only used by virtualbox and xhyve
NFSShare []string
NFSSharesRoot string
UUID string // Only used by hyperkit to restore the mac address
}

// Config contains machine and k8s config
Expand Down

0 comments on commit cebd704

Please sign in to comment.