Failed to setup kubeconfig when starting minikube

12/11/2019

I have installed kubectl and minikube on my windows environment, but when running minikube start it creates the VM on vitualBox but I got this error when it trying to prepare kubernetes on Docker.

C:\Users\asusstrix>minikube start

* minikube v1.6.0 on Microsoft Windows 10 Home 10.0.18362 Build 18362
* Selecting 'virtualbox' driver from user configuration (alternates: [])
* Creating virtualbox VM (CPUs=2, Memory=2000MB, Disk=20000MB) ...
* Preparing Kubernetes v1.17.0 on Docker '19.03.5' ...
*
X Failed to setup kubeconfig: writing kubeconfig: Error writing file C:\Users\asusstrix/.kube/config: error acquiring lock for C:\Users\asusstrix/.kube/config: timeout acquiring mutex
*
* Sorry that minikube crashed. If this was unexpected, we would love to hear from you:
  - https://github.com/kubernetes/minikube/issues/new/choose
-- NFAIHI
docker
kubectl
kubernetes
minikube

1 Answer

12/11/2019

According to the official documentation:

To confirm successful installation of both a hypervisor and Minikube, you can run the following command to start up a local Kubernetes cluster:

minikube start --vm-driver=<driver_name>

For setting the --vm-driver with minikube start, enter the name of the hypervisor you installed in lowercase letters where is mentioned below. A full list of --vm-driver values is available in specifying the VM driver documentation.

So in your case it would be: minikube start --vm-driver=<virtualbox>

If you want ot make sure your previous steps were correct you can go through the whole tutorial.

Please let me know if that helped.

EDIT:

There is a Github thread showing the same issue.

Basically you still should use minikube start --vm-driver=<driver_name> but it will not work with v1.6.0 yet. Consider downgrading to v1.5.2 instead.

-- OhHiMark
Source: StackOverflow