Minikube hanging on Creating hyperv VM

6/5/2020

Heads up: I need Hyper-V as VM driver because I want to be able to use the ingress addon; using Docker as the driver will not allow the use of addons in Windows.

I am using Minikube v1.11.0 and Kubernetes v1.18.3. When I am trying to create and launch a Minikube cluster according to this tutorial with Hyper-V in PowerShell it keeps hanging on 'Creating hyperv VM:

PS C:\WINDOWS\system32> minikube start --vm-driver hyperv --hyperv-virtual-switch "Primary Virtual Switch"
* minikube v1.11.0 on Microsoft Windows 10 Pro 10.0.18363 Build 18363
  - KUBECONFIG=~/.kube/config
* Using the hyperv driver based on user configuration
* Starting control plane node minikube in cluster minikube
* Creating hyperv VM (CPUs=4, Memory=4096MB, Disk=20000MB) ...

After about 10 minutes it goes further and crashes with this errors:

* Stopping "minikube" in hyperv ...
* Powering off "minikube" via SSH ...
* Deleting "minikube" in hyperv ...
! StartHost failed, but will try again: creating host: create host timed out in 240.000000 seconds
E0605 19:02:43.905739   30748 main.go:106] libmachine: [stderr =====>] : Hyper-V\Get-VM : Hyper-V was unable to find a virtual machine with name "minikube".
At line:1 char:3
+ ( Hyper-V\Get-VM minikube ).state
+   ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (minikube:String) [Get-VM], VirtualizationException
    + FullyQualifiedErrorId : InvalidParameter,Microsoft.HyperV.PowerShell.Commands.GetVM

...
Multiple E0605 errors
...

* Failed to start hyperv VM. "minikube start" may fix it: creating host: create host timed out in 240.000000 seconds
*
* [CREATE_TIMEOUT] error provisioning host Failed to start host: creating host: create host timed out in 240.000000 seconds
* Suggestion: Try 'minikube delete', and disable any conflicting VPN or firewall software
* Related issue: https://github.com/kubernetes/minikube/issues/7072

What to do?

-- marcuse
hyper-v
kubernetes
minikube

2 Answers

6/5/2020

According to the tutorial you followed you have to make a new virtual network switch in the Hyper-V Manager with the type External. The author does not explain why the network switch has to be external, other than that this configuration is best for avoiding headaches with Minikube not working properly with other software.

For some reason the External type of the virtual network switch was the problem, instead of External type use the Internal type for your virtual network switch in the Hyper-V Manager. Then run the following command to delete the wrong configurated cluster and to clean up:

minikube delete

Now, re-run the create/launch command for your Minikube cluster with your internal virtual network switch:

minikube start --vm-driver hyperv --hyperv-virtual-switch "Your Internal Virtual Switch"

Now you're all set with your new cluster when it finishes correctly!

-- marcuse
Source: StackOverflow

1/31/2021

Fix On Azure VM in Windows Server 2019:

  1. Check if minikube VM has an IP Address in Networking tab

    • If NO IP address and no DHCP is running in VM, then go to next step
  2. Create new InternalNAT switch:

Powershell:

New-VMSwitch -Name "InternalNAT" -SwitchType Internal 

Get-NetAdapter
# Take note of the "ifIndex" for the virtual switch you just created, assuming 13

New-NetIPAddress -IPAddress 192.168.0.1 -PrefixLength 24 -InterfaceIndex 13

New-NetNat -Name "InternalNat" -InternalIPInterfaceAddressPrefix 192.168.0.0/24
  1. Create DHCP Server
  • Create new scope for 192.168.. (or any range, note down this range)
  1. Delete and Re-create minikube and use "InternalNat" switch

    minikube start --vm-driver hyperv --hyperv-virtual-switch "InternalNAT"

    1: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/nested-virtualization#set-up-internet-connectivity-for-the-guest-virtual-machine

-- Lydon Ch
Source: StackOverflow