Minikube: writing kubeconfig: Error writing file : open : no such file or directory

Created on 15 Apr 2019  ยท  9Comments  ยท  Source: kubernetes/minikube

@james-dc commented on Sat Apr 13 2019

This is a Bug Report



Problem:
Running minikube start as the setup guide suggests yields the following failure:

james@james-desktop:~$ cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.10
DISTRIB_CODENAME=cosmic
DISTRIB_DESCRIPTION="Ubuntu 18.10"
NAME="Ubuntu"
VERSION="18.10 (Cosmic Cuttlefish)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.10"
VERSION_ID="18.10"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=cosmic
UBUNTU_CODENAME=cosmic
james@james-desktop:~$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
>   && chmod +x minikube
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 38.2M  100 38.2M    0     0  6992k      0  0:00:05  0:00:05 --:--:-- 7456k
james@james-desktop:~$ sudo cp minikube /usr/local/bin && rm minikube
james@james-desktop:~$ minikube start
๐Ÿ˜„  minikube v1.0.0 on linux (amd64)
๐Ÿคน  Downloading Kubernetes v1.14.0 images in the background ...
2019/04/13 20:05:33 No matching credentials were found, falling back on anonymous
2019/04/13 20:05:33 No matching credentials were found, falling back on anonymous
2019/04/13 20:05:33 No matching credentials were found, falling back on anonymous
2019/04/13 20:05:33 No matching credentials were found, falling back on anonymous
2019/04/13 20:05:33 No matching credentials were found, falling back on anonymous
2019/04/13 20:05:33 No matching credentials were found, falling back on anonymous
2019/04/13 20:05:33 No matching credentials were found, falling back on anonymous
2019/04/13 20:05:33 No matching credentials were found, falling back on anonymous
2019/04/13 20:05:33 No matching credentials were found, falling back on anonymous
2019/04/13 20:05:33 No matching credentials were found, falling back on anonymous
๐Ÿ”ฅ  Creating virtualbox VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
๐Ÿ’ฟ  Downloading Minikube ISO ...
2019/04/13 20:05:33 No matching credentials were found, falling back on anonymous
2019/04/13 20:05:33 No matching credentials were found, falling back on anonymous
2019/04/13 20:05:33 No matching credentials were found, falling back on anonymous
 142.88 MB / 142.88 MB [============================================] 100.00% 0s
๐Ÿ“ถ  "minikube" IP address is 192.168.99.105
๐Ÿณ  Configuring Docker as the container runtime ...
๐Ÿณ  Version of container runtime is 18.06.2-ce
โŒ›  Waiting for image downloads to complete ...
โœจ  Preparing Kubernetes environment ...
๐Ÿ’พ  Downloading kubeadm v1.14.0
๐Ÿ’พ  Downloading kubelet v1.14.0

๐Ÿ’ฃ  Failed to setup kubeconfig: writing kubeconfig: Error writing file : open : no such file or directory

๐Ÿ˜ฟ  Sorry that minikube crashed. If this was unexpected, we would love to hear from you:
๐Ÿ‘‰  https://github.com/kubernetes/minikube/issues/new

I found running sudo minikube start lets minikube start successfully:

james@james-desktop:~$ sudo minikube start
๐Ÿ˜„  minikube v1.0.0 on linux (amd64)
๐Ÿคน  Downloading Kubernetes v1.14.0 images in the background ...
๐Ÿ”ฅ  Creating virtualbox VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
๐Ÿ“ถ  "minikube" IP address is 192.168.99.107
๐Ÿณ  Configuring Docker as the container runtime ...
๐Ÿณ  Version of container runtime is 18.06.2-ce
โŒ›  Waiting for image downloads to complete ...
โœจ  Preparing Kubernetes environment ...
๐Ÿšœ  Pulling images required by Kubernetes v1.14.0 ...
๐Ÿš€  Launching Kubernetes v1.14.0 using kubeadm ... 
โŒ›  Waiting for pods: apiserver proxy etcd scheduler controller dns
๐Ÿ”‘  Configuring cluster permissions ...
๐Ÿค”  Verifying component health .....
๐Ÿ’—  kubectl is now configured to use "minikube"
๐Ÿ’ก  For best results, install kubectl: https://kubernetes.io/docs/tasks/tools/install-kubectl/
๐Ÿ„  Done! Thank you for using minikube!

However any further interaction with minikube / kubectl also requires the use of sudo to function properly which is not desirable.

Page to Update:
https://kubernetes.io/docs/tasks/tools/install-minikube/

help wanted kinbug prioritbacklog 2019q2

Most helpful comment

So, I had KUBECONFIG set to a list of configs for various clusters I was working with. Apparently, this was prohibiting Minikube from starting. To resolve, I unset KUBECONFIG before starting minikube.

unset KUBECONFIG
minikube start

When you're done using minikube and have stopped it, you can source your .bashrc or .bash_profile (wherever KUBECONFIG is defined) or restart your terminal and resume working with the other clusters.

Hope this helps someone.

All 9 comments

The error indicates that the filename was "":

        return errors.Wrapf(err, "Error writing file %s", filename)

I'm having the same issue. Which file is this referring to and how is it set? Is it ~/.kube/config?

So, I had KUBECONFIG set to a list of configs for various clusters I was working with. Apparently, this was prohibiting Minikube from starting. To resolve, I unset KUBECONFIG before starting minikube.

unset KUBECONFIG
minikube start

When you're done using minikube and have stopped it, you can source your .bashrc or .bash_profile (wherever KUBECONFIG is defined) or restart your terminal and resume working with the other clusters.

Hope this helps someone.

same here with minikube 1.3.0 on macos 10.14.6

minikube start --v=3
๐Ÿ˜„  minikube v1.3.0 on Darwin 10.14.6
๐Ÿ’ก  Tip: Use 'minikube start -p <name>' to create a new cluster, or 'minikube delete' to delete this one.
๐Ÿƒ  Using the running virtualbox "minikube" VM ...
โŒ›  Waiting for the host to be provisioned ...
Waiting for SSH to be available...
Detecting the provisioner...
Setting Docker configuration on the remote daemon...
๐Ÿณ  Preparing Kubernetes v1.15.2 on Docker 18.09.8 ...

๐Ÿ’ฃ  Failed to setup kubeconfig: writing kubeconfig: Error writing file : open : no such file or directory

๐Ÿ˜ฟ  Sorry that minikube crashed.

@den-is Can you share the output of env | grep KUBECONFIG?

It seems possible that you have KUBECONFIG set to an invalid location in your environment. Alternatively, please share the output of:

minikube start --alsologtostderr -v=4

Thanks!

I am curious why your customse kubeconfig was not usable by minikube ! if this is the case ! minikube shouldn't have cared ! if it doest, we need to detect and let user know by a solution message.

@tstromberg and I think that is pointed to right location

env | grep -i kube
KUBECONFIG=:/Users/den/.kube/config:/Users/den/.kube/config

I'm not sure why there is duplicate, but imagine it doesn't exist there, and there are many other "concatenated" kubeconfigs for different clusters

I had the same issue, the problem is the initial : in KUBECONFIG

KUBECONFIG=:/Users/den/.kube/config:/Users/den/.kube/config

should be

KUBECONFIG=/Users/den/.kube/config:/Users/den/.kube/config

Probably you have KUBECONFIG=$KUBECONFIG:/Users/den/.kube/config in your ~/.bash_profile

Although the error message could be clearer

@carlossg good point !

indeed I have export KUBECONFIG=$KUBECONFIG:$HOME/.kube/config

error message could be clearer and minikube can be smarter about empty strings too

Was this page helpful?
0 / 5 - 0 ratings