diff --git a/cmd/minikube/cmd/start_flags.go b/cmd/minikube/cmd/start_flags.go index 77511de60212..098916ef4a34 100644 --- a/cmd/minikube/cmd/start_flags.go +++ b/cmd/minikube/cmd/start_flags.go @@ -194,7 +194,7 @@ func initDriverFlags() { startCmd.Flags().String(kvmQemuURI, "qemu:///system", "The KVM QEMU connection URI. (kvm2 driver only)") startCmd.Flags().Bool(kvmGPU, false, "Enable experimental NVIDIA GPU support in minikube") startCmd.Flags().Bool(kvmHidden, false, "Hide the hypervisor signature from the guest in minikube (kvm2 driver only)") - startCmd.Flags().Int(kvmNUMACount, 1, "Simulate numa node count in minikube. (kvm2 driver only)") + startCmd.Flags().Int(kvmNUMACount, 1, "Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)") // virtualbox startCmd.Flags().String(hostOnlyCIDR, "192.168.99.1/24", "The CIDR to be used for the minikube VM (virtualbox driver only)") @@ -313,6 +313,19 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k out.WarningT("--network flag is only valid with the docker/podman drivers, it will be ignored") } + if viper.GetInt(kvmNUMACount) < 1 || viper.GetInt(kvmNUMACount) > 8 { + exit.Message(reason.Usage, "--kvm-numa-count range is 1-8") + } + if viper.GetInt(kvmNUMACount) > 1 { + v, err := pkgutil.ParseKubernetesVersion(k8sVersion) + if err != nil { + exit.Message(reason.Usage, "invalid kubernetes version") + } + if v.LT(semver.Version{Major: 1,Minor: 18}){ + exit.Message(reason.Usage, "numa node is only supported on k8s v1.18 and later") + } + } + cc = config.ClusterConfig{ Name: ClusterFlagValue(), KeepContext: viper.GetBool(keepContext), diff --git a/pkg/drivers/kvm/kvm.go b/pkg/drivers/kvm/kvm.go index c7adc02a7052..5843557e0469 100644 --- a/pkg/drivers/kvm/kvm.go +++ b/pkg/drivers/kvm/kvm.go @@ -320,7 +320,7 @@ func (d *Driver) Create() (err error) { } if d.NUMANodeCount > 1 { - NUMAXML, err := GetNUMAXml(d.CPU, d.Memory, d.NUMANodeCount) + NUMAXML, err := NumaXml(d.CPU, d.Memory, d.NUMANodeCount) if err != nil { return errors.Wrap(err, "creating NUMA XML") } diff --git a/pkg/drivers/kvm/numa.go b/pkg/drivers/kvm/numa.go index c902b479f1c1..4ac08a59a066 100644 --- a/pkg/drivers/kvm/numa.go +++ b/pkg/drivers/kvm/numa.go @@ -40,9 +40,9 @@ type NUMA struct { CPUTopology string } -// GetNUMAXml generate numa xml +// NumaXml generate numa xml // evenly distributed cpu core & memory to each numa node -func GetNUMAXml(cpu, memory, numaCount int) (string, error) { +func NumaXml(cpu, memory, numaCount int) (string, error) { if numaCount < 1 { return "", fmt.Errorf("numa node count must >= 1") } diff --git a/pkg/drivers/kvm/numa_test.go b/pkg/drivers/kvm/numa_test.go index 4a6f553eec9b..103d8bf08d17 100644 --- a/pkg/drivers/kvm/numa_test.go +++ b/pkg/drivers/kvm/numa_test.go @@ -22,12 +22,12 @@ import ( ) func TestGetNUMAXml(t *testing.T) { - _, err := GetNUMAXml(1, 1024, 0) + _, err := NumaXml(1, 1024, 0) if err == nil { t.Errorf("check invalid numa count failed: %s", err) } - xml, err := GetNUMAXml(10, 10240, 8) + xml, err := NumaXml(10, 10240, 8) expXML := ` diff --git a/site/content/en/docs/commands/start.md b/site/content/en/docs/commands/start.md index 46fcc4a64625..b61eb3fa50be 100644 --- a/site/content/en/docs/commands/start.md +++ b/site/content/en/docs/commands/start.md @@ -70,7 +70,7 @@ minikube start [flags] --kvm-gpu Enable experimental NVIDIA GPU support in minikube --kvm-hidden Hide the hypervisor signature from the guest in minikube (kvm2 driver only) --kvm-network string The KVM network name. (kvm2 driver only) (default "default") - --kvm-numa-count int Simulate numa node count in minikube. (kvm2 driver only) (default 1) + --kvm-numa-count int Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only) (default 1) --kvm-qemu-uri string The KVM QEMU connection URI. (kvm2 driver only) (default "qemu:///system") --memory string Amount of RAM to allocate to Kubernetes (format: [], where unit = b, k, m or g). --mount This will start the mount daemon and automatically mount files into minikube.