From fbb1d97cf195b0cdfc21e911147286c0b7cee496 Mon Sep 17 00:00:00 2001 From: David Newman Date: Fri, 22 Nov 2019 13:50:12 -0500 Subject: [PATCH] feat(virtualbox): Users and set nat-nic-type and host-only-nic-type --- cmd/minikube/cmd/start.go | 6 ++++++ go.mod | 3 +++ pkg/minikube/config/types.go | 2 ++ pkg/minikube/registry/drvs/virtualbox/virtualbox.go | 7 +++---- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 1be0db1f1205..f186345adbc7 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -121,6 +121,8 @@ const ( minimumCPUS = 2 minimumDiskSize = "2000mb" autoUpdate = "auto-update-drivers" + hostOnlyNicType = "host-only-nic-type" + natNicType = "nat-nic-type" ) var ( @@ -208,6 +210,8 @@ func initDriverFlags() { startCmd.Flags().Bool(dnsProxy, false, "Enable proxy for NAT DNS requests (virtualbox driver only)") startCmd.Flags().Bool(hostDNSResolver, true, "Enable host resolver for NAT DNS requests (virtualbox driver only)") startCmd.Flags().Bool(noVTXCheck, false, "Disable checking for the availability of hardware virtualization before the vm is started (virtualbox driver only)") + startCmd.Flags().String(hostOnlyNicType, "virtio", "NIC Type used for host only network. One of Am79C970A, Am79C973, 82540EM, 82543GC, 82545EM, or virtio (virtualbox driver only)") + startCmd.Flags().String(natNicType, "virtio", "NIC Type used for host only network. One of Am79C970A, Am79C973, 82540EM, 82543GC, 82545EM, or virtio (virtualbox driver only)") // hyperkit startCmd.Flags().StringSlice(vsockPorts, []string{}, "List of guest VSock ports that should be exposed as sockets on the host (hyperkit driver only)") @@ -912,6 +916,8 @@ func generateCfgFromFlags(cmd *cobra.Command, k8sVersion string, drvName string) NoVTXCheck: viper.GetBool(noVTXCheck), DNSProxy: viper.GetBool(dnsProxy), HostDNSResolver: viper.GetBool(hostDNSResolver), + HostOnlyNicType: viper.GetString(hostOnlyNicType), + NatNicType: viper.GetString(natNicType), KubernetesConfig: cfg.KubernetesConfig{ KubernetesVersion: k8sVersion, NodePort: viper.GetInt(apiServerPort), diff --git a/go.mod b/go.mod index 8976fb1bece0..46cf856a6859 100644 --- a/go.mod +++ b/go.mod @@ -21,11 +21,14 @@ require ( github.com/docker/machine v0.7.1-0.20190718054102-a555e4f7a8f5 // version is 0.7.1 to pin to a555e4f7a8f5 github.com/elazarl/goproxy v0.0.0-20190421051319-9d40249d3c2f github.com/elazarl/goproxy/ext v0.0.0-20190421051319-9d40249d3c2f // indirect + github.com/ghodss/yaml v1.0.0 // indirect github.com/go-ole/go-ole v1.2.4 // indirect github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b + github.com/google/btree v1.0.0 // indirect github.com/google/go-cmp v0.3.0 github.com/gorilla/mux v1.7.1 // indirect + github.com/grpc-ecosystem/grpc-gateway v1.5.0 // indirect github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce // indirect github.com/hashicorp/go-getter v1.4.0 github.com/hashicorp/go-multierror v0.0.0-20160811015721-8c5f0ad93604 // indirect diff --git a/pkg/minikube/config/types.go b/pkg/minikube/config/types.go index 2ecdc006841c..cc8990aa0ed0 100644 --- a/pkg/minikube/config/types.go +++ b/pkg/minikube/config/types.go @@ -61,6 +61,8 @@ type MachineConfig struct { DNSProxy bool // Only used by virtualbox HostDNSResolver bool // Only used by virtualbox KubernetesConfig KubernetesConfig + HostOnlyNicType string // Only used by virtualbox + NatNicType string // Only used by virtualbox } // KubernetesConfig contains the parameters used to configure the VM Kubernetes. diff --git a/pkg/minikube/registry/drvs/virtualbox/virtualbox.go b/pkg/minikube/registry/drvs/virtualbox/virtualbox.go index cc4e266b7648..4f6edf70c5eb 100644 --- a/pkg/minikube/registry/drvs/virtualbox/virtualbox.go +++ b/pkg/minikube/registry/drvs/virtualbox/virtualbox.go @@ -31,8 +31,7 @@ import ( ) const ( - defaultVirtualboxNicType = "virtio" - docURL = "https://minikube.sigs.k8s.io/docs/reference/drivers/virtualbox/" + docURL = "https://minikube.sigs.k8s.io/docs/reference/drivers/virtualbox/" ) func init() { @@ -57,8 +56,8 @@ func configure(mc config.MachineConfig) interface{} { d.HostOnlyCIDR = mc.HostOnlyCIDR d.NoShare = mc.DisableDriverMounts d.NoVTXCheck = mc.NoVTXCheck - d.NatNicType = defaultVirtualboxNicType - d.HostOnlyNicType = defaultVirtualboxNicType + d.NatNicType = mc.NatNicType + d.HostOnlyNicType = mc.HostOnlyNicType d.DNSProxy = mc.DNSProxy d.HostDNSResolver = mc.HostDNSResolver return d