diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index aae4fc1794a0..34f19280f57f 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -68,6 +68,7 @@ const ( mountString = "mount-string" disableDriverMounts = "disable-driver-mounts" cacheImages = "cache-images" + uuid = "uuid" ) var ( @@ -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)) diff --git a/pkg/drivers/hyperkit/driver.go b/pkg/drivers/hyperkit/driver.go index 513d50b4d937..5fe4bceb811a 100644 --- a/pkg/drivers/hyperkit/driver.go +++ b/pkg/drivers/hyperkit/driver.go @@ -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" @@ -59,6 +58,7 @@ type Driver struct { Cmdline string NFSShares []string NFSSharesRoot string + UUID string } func NewDriver(hostName, storePath string) *Driver { @@ -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 diff --git a/pkg/minikube/cluster/cluster_darwin.go b/pkg/minikube/cluster/cluster_darwin.go index bf38a42dc6d0..336661731047 100644 --- a/pkg/minikube/cluster/cluster_darwin.go +++ b/pkg/minikube/cluster/cluster_darwin.go @@ -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" @@ -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(), } } diff --git a/pkg/minikube/cluster/types.go b/pkg/minikube/cluster/types.go index 7219b24ccebb..e535d05f96d6 100644 --- a/pkg/minikube/cluster/types.go +++ b/pkg/minikube/cluster/types.go @@ -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