Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solution message for file permission for .kube/config #5714

Closed
gleich opened this issue Oct 24, 2019 · 15 comments
Closed

solution message for file permission for .kube/config #5714

gleich opened this issue Oct 24, 2019 · 15 comments
Labels
co/hyperkit Hyperkit related issues co/none-driver co/virtualbox good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/ux priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. triage/needs-information Indicates an issue needs more information in order to work on it.

Comments

@gleich
Copy link

gleich commented Oct 24, 2019

The exact command to reproduce the issue:
minikube start

The full output of the command that failed:

😄  minikube v1.4.0 on Darwin 10.14.6
🔥  Creating virtualbox VM (CPUs=2, Memory=2000MB, Disk=20000MB) ...
🐳  Preparing Kubernetes v1.16.0 on Docker 18.09.9 ...

💣  Failed to setup kubeconfig: writing kubeconfig: Error writing file /Users/matthewgleich/.kube/config: error writing file /Users/matthewgleich/.kube/config: open /Users/matthewgleich/.kube/config: permission denied

😿  Sorry that minikube crashed. If this was unexpected, we would love to hear from you:
👉  https://github.com/kubernetes/minikube/issues/new/choose

The output of the minikube logs command:

==> Docker <==
-- Logs begin at Thu 2019-10-24 00:24:54 UTC, end at Thu 2019-10-24 00:30:48 UTC. --
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.986313584Z" level=info msg="loading plugin "io.containerd.gc.v1.scheduler"..." type=io.containerd.gc.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.986418056Z" level=info msg="loading plugin "io.containerd.service.v1.containers-service"..." type=io.containerd.service.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.986467595Z" level=info msg="loading plugin "io.containerd.service.v1.content-service"..." type=io.containerd.service.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.986506678Z" level=info msg="loading plugin "io.containerd.service.v1.diff-service"..." type=io.containerd.service.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.986545774Z" level=info msg="loading plugin "io.containerd.service.v1.images-service"..." type=io.containerd.service.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.986589947Z" level=info msg="loading plugin "io.containerd.service.v1.leases-service"..." type=io.containerd.service.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.986628044Z" level=info msg="loading plugin "io.containerd.service.v1.namespaces-service"..." type=io.containerd.service.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.986664195Z" level=info msg="loading plugin "io.containerd.service.v1.snapshots-service"..." type=io.containerd.service.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.986700578Z" level=info msg="loading plugin "io.containerd.runtime.v1.linux"..." type=io.containerd.runtime.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.986937016Z" level=info msg="loading plugin "io.containerd.runtime.v2.task"..." type=io.containerd.runtime.v2
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.987047338Z" level=info msg="loading plugin "io.containerd.monitor.v1.cgroups"..." type=io.containerd.monitor.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.987383806Z" level=info msg="loading plugin "io.containerd.service.v1.tasks-service"..." type=io.containerd.service.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.987451240Z" level=info msg="loading plugin "io.containerd.internal.v1.restart"..." type=io.containerd.internal.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.987510362Z" level=info msg="loading plugin "io.containerd.grpc.v1.containers"..." type=io.containerd.grpc.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.987548198Z" level=info msg="loading plugin "io.containerd.grpc.v1.content"..." type=io.containerd.grpc.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.987583862Z" level=info msg="loading plugin "io.containerd.grpc.v1.diff"..." type=io.containerd.grpc.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.987619206Z" level=info msg="loading plugin "io.containerd.grpc.v1.events"..." type=io.containerd.grpc.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.987653222Z" level=info msg="loading plugin "io.containerd.grpc.v1.healthcheck"..." type=io.containerd.grpc.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.987692047Z" level=info msg="loading plugin "io.containerd.grpc.v1.images"..." type=io.containerd.grpc.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.987731306Z" level=info msg="loading plugin "io.containerd.grpc.v1.leases"..." type=io.containerd.grpc.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.987766756Z" level=info msg="loading plugin "io.containerd.grpc.v1.namespaces"..." type=io.containerd.grpc.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.987801606Z" level=info msg="loading plugin "io.containerd.internal.v1.opt"..." type=io.containerd.internal.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.987876875Z" level=info msg="loading plugin "io.containerd.grpc.v1.snapshots"..." type=io.containerd.grpc.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.987918317Z" level=info msg="loading plugin "io.containerd.grpc.v1.tasks"..." type=io.containerd.grpc.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.987954906Z" level=info msg="loading plugin "io.containerd.grpc.v1.version"..." type=io.containerd.grpc.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.987990322Z" level=info msg="loading plugin "io.containerd.grpc.v1.introspection"..." type=io.containerd.grpc.v1
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.988125286Z" level=info msg=serving... address="/var/run/docker/containerd/containerd-debug.sock"
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.988260940Z" level=info msg=serving... address="/var/run/docker/containerd/containerd.sock"
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.988301297Z" level=info msg="containerd successfully booted in 0.008929s"
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.992935857Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc0006fc400, READY" module=grpc
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.997001193Z" level=info msg="systemd-resolved is running, so using resolvconf: /run/systemd/resolve/resolv.conf"
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.997692624Z" level=info msg="parsed scheme: \"unix\"" module=grpc
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.997775578Z" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.997908087Z" level=info msg="parsed scheme: \"unix\"" module=grpc
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.997951758Z" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.998295246Z" level=info msg="ccResolverWrapper: sending new addresses to cc: [{unix:///var/run/docker/containerd/containerd.sock 0  <nil>}]" module=grpc
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.998331213Z" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.998365345Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc000152e90, CONNECTING" module=grpc
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.998918875Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc000152e90, READY" module=grpc
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.999222571Z" level=info msg="ccResolverWrapper: sending new addresses to cc: [{unix:///var/run/docker/containerd/containerd.sock 0  <nil>}]" module=grpc
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.999824433Z" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
Oct 24 00:25:01 minikube dockerd[2396]: time="2019-10-24T00:25:01.999875395Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc0001531c0, CONNECTING" module=grpc
Oct 24 00:25:02 minikube dockerd[2396]: time="2019-10-24T00:25:02.000228311Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc0001531c0, READY" module=grpc
Oct 24 00:25:02 minikube dockerd[2396]: time="2019-10-24T00:25:02.018533644Z" level=info msg="Graph migration to content-addressability took 0.00 seconds"
Oct 24 00:25:02 minikube dockerd[2396]: time="2019-10-24T00:25:02.018974906Z" level=warning msg="Your kernel does not support cgroup blkio weight"
Oct 24 00:25:02 minikube dockerd[2396]: time="2019-10-24T00:25:02.019059509Z" level=warning msg="Your kernel does not support cgroup blkio weight_device"
Oct 24 00:25:02 minikube dockerd[2396]: time="2019-10-24T00:25:02.019111706Z" level=warning msg="Your kernel does not support cgroup blkio throttle.read_bps_device"
Oct 24 00:25:02 minikube dockerd[2396]: time="2019-10-24T00:25:02.019157566Z" level=warning msg="Your kernel does not support cgroup blkio throttle.write_bps_device"
Oct 24 00:25:02 minikube dockerd[2396]: time="2019-10-24T00:25:02.019199877Z" level=warning msg="Your kernel does not support cgroup blkio throttle.read_iops_device"
Oct 24 00:25:02 minikube dockerd[2396]: time="2019-10-24T00:25:02.019242547Z" level=warning msg="Your kernel does not support cgroup blkio throttle.write_iops_device"
Oct 24 00:25:02 minikube dockerd[2396]: time="2019-10-24T00:25:02.019987749Z" level=info msg="Loading containers: start."
Oct 24 00:25:02 minikube dockerd[2396]: time="2019-10-24T00:25:02.112680305Z" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
Oct 24 00:25:02 minikube dockerd[2396]: time="2019-10-24T00:25:02.228969844Z" level=info msg="Loading containers: done."
Oct 24 00:25:02 minikube dockerd[2396]: time="2019-10-24T00:25:02.276903069Z" level=warning msg="failed to retrieve runc version: unknown output format: runc version commit: 425e105d5a03fabd737a126ad93d62a9eeede87f\nspec: 1.0.1-dev\n"
Oct 24 00:25:02 minikube dockerd[2396]: time="2019-10-24T00:25:02.277441773Z" level=warning msg="failed to retrieve docker-init version: exec: \"docker-init\": executable file not found in $PATH"
Oct 24 00:25:02 minikube dockerd[2396]: time="2019-10-24T00:25:02.286511178Z" level=info msg="Docker daemon" commit=039a7df9ba graphdriver(s)=overlay2 version=18.09.9
Oct 24 00:25:02 minikube dockerd[2396]: time="2019-10-24T00:25:02.286688276Z" level=info msg="Daemon has completed initialization"
Oct 24 00:25:02 minikube dockerd[2396]: time="2019-10-24T00:25:02.310436157Z" level=info msg="API listen on /var/run/docker.sock"
Oct 24 00:25:02 minikube systemd[1]: Started Docker Application Container Engine.
Oct 24 00:25:02 minikube dockerd[2396]: time="2019-10-24T00:25:02.311012373Z" level=info msg="API listen on [::]:2376"

==> container status <==
time="2019-10-24T00:30:50Z" level=fatal msg="failed to connect: failed to connect, make sure you are running as root and the runtime has been started: context deadline exceeded"
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

==> dmesg <==
[  +5.006137] hpet1: lost 319 rtc interrupts
[Oct24 00:26] hpet1: lost 318 rtc interrupts
[  +5.010518] hpet1: lost 319 rtc interrupts
[  +5.010660] hpet1: lost 320 rtc interrupts
[  +5.008520] hpet1: lost 318 rtc interrupts
[  +5.004560] hpet1: lost 318 rtc interrupts
[  +5.005791] hpet1: lost 320 rtc interrupts
[  +5.010623] hpet1: lost 318 rtc interrupts
[  +5.000262] hpet1: lost 319 rtc interrupts
[  +5.004737] hpet1: lost 319 rtc interrupts
[  +5.004435] hpet1: lost 319 rtc interrupts
[  +5.001267] hpet1: lost 319 rtc interrupts
[  +2.321268] NFSD: Unable to end grace period: -110
[  +2.681877] hpet1: lost 318 rtc interrupts
[Oct24 00:27] hpet1: lost 320 rtc interrupts
[  +5.004691] hpet1: lost 318 rtc interrupts
[  +5.006344] hpet1: lost 318 rtc interrupts
[  +5.006748] hpet1: lost 320 rtc interrupts
[  +5.005789] hpet1: lost 319 rtc interrupts
[  +5.007323] hpet1: lost 318 rtc interrupts
[  +5.007288] hpet1: lost 319 rtc interrupts
[  +5.001100] hpet1: lost 318 rtc interrupts
[  +5.005423] hpet1: lost 318 rtc interrupts
[  +5.007248] hpet1: lost 319 rtc interrupts
[  +4.999038] hpet1: lost 318 rtc interrupts
[  +5.008323] hpet1: lost 319 rtc interrupts
[Oct24 00:28] hpet1: lost 320 rtc interrupts
[  +5.002216] hpet1: lost 318 rtc interrupts
[  +5.001339] hpet1: lost 318 rtc interrupts
[  +5.004050] hpet1: lost 319 rtc interrupts
[  +5.001594] hpet1: lost 318 rtc interrupts
[  +5.009486] hpet1: lost 319 rtc interrupts
[  +5.003824] hpet1: lost 319 rtc interrupts
[  +5.000463] hpet1: lost 318 rtc interrupts
[  +5.010095] hpet1: lost 319 rtc interrupts
[  +5.006315] hpet1: lost 318 rtc interrupts
[  +5.011600] hpet1: lost 319 rtc interrupts
[  +5.009455] hpet1: lost 319 rtc interrupts
[Oct24 00:29] hpet1: lost 319 rtc interrupts
[  +5.002996] hpet1: lost 319 rtc interrupts
[  +5.024658] hpet1: lost 320 rtc interrupts
[  +5.004691] hpet1: lost 319 rtc interrupts
[  +5.006162] hpet1: lost 318 rtc interrupts
[  +5.000821] hpet1: lost 318 rtc interrupts
[  +5.005783] hpet1: lost 319 rtc interrupts
[  +5.013573] hpet1: lost 319 rtc interrupts
[  +5.006127] hpet1: lost 318 rtc interrupts
[  +5.002262] hpet1: lost 318 rtc interrupts
[  +5.013687] hpet1: lost 319 rtc interrupts
[  +5.000237] hpet1: lost 319 rtc interrupts
[Oct24 00:30] hpet1: lost 319 rtc interrupts
[  +5.006542] hpet1: lost 319 rtc interrupts
[  +5.011283] hpet1: lost 320 rtc interrupts
[  +5.010951] hpet1: lost 318 rtc interrupts
[  +5.007912] hpet1: lost 319 rtc interrupts
[  +5.003408] hpet1: lost 318 rtc interrupts
[  +5.003147] hpet1: lost 318 rtc interrupts
[  +5.000240] hpet1: lost 318 rtc interrupts
[  +5.010074] hpet1: lost 319 rtc interrupts
[  +5.008476] hpet1: lost 318 rtc interrupts

==> kernel <==
 00:30:51 up 6 min,  0 users,  load average: 0.01, 0.28, 0.19
Linux minikube 4.15.0 #1 SMP Wed Sep 18 07:44:58 PDT 2019 x86_64 GNU/Linux
PRETTY_NAME="Buildroot 2018.05.3"

==> kubelet <==
-- Logs begin at Thu 2019-10-24 00:24:54 UTC, end at Thu 2019-10-24 00:30:51 UTC. --
-- No entries --

The operating system version:
macOS Mojave Version 10.14.16

@medyagh
Copy link
Member

medyagh commented Oct 30, 2019

I am curious can you acutally read your kubeconfig file ?
cat you see output of

cat /Users/matthewgleich/.kube/config
and could you please share the output of

ls -lah /Users/matthewgleich/.kube/config

@medyagh medyagh added triage/needs-information Indicates an issue needs more information in order to work on it. co/virtualbox labels Oct 30, 2019
@medyagh medyagh changed the title Permission Denied with minikube start Error writing .kube/config Oct 30, 2019
@gleich
Copy link
Author

gleich commented Oct 30, 2019

Output of cat /Users/matthewgleich/.kube/config:

cat: /Users/matthewgleich/.kube/config: No such file or directory

Output of ls -lah /Users/matthewgleich/.kube/config:

ls: /Users/matthewgleich/.kube/config: No such file or directory

@medyagh

@medyagh
Copy link
Member

medyagh commented Nov 4, 2019

@Matt-Gleich thanks for getting back to me ! I am curious do you still have this issue with the latest version ?

and also do you happen to be running another application that is is openinng/writing to kbue config at the same time ?

@gleich
Copy link
Author

gleich commented Nov 5, 2019

@medyagh
I don't have another issue but when I reinstalled it I started to get this error:

💣  Failed to setup kubeconfig: writing kubeconfig: Error writing file /Users/matthewgleich/.kube/config: error writing file /Users/matthewgleich/.kube/config: open /Users/matthewgleich/.kube/config: permission denied

I asked in the #minikube channel in the Kubernetes Slack Channel and got told to run the following command:

sudo chown -R $USER ~/.kube

This ended up fixing it although it runs in hyperkit instead of virtualbox

@gleich
Copy link
Author

gleich commented Nov 5, 2019

Could this error message have a message telling the user to run this command?

@medyagh
Copy link
Member

medyagh commented Nov 6, 2019

@Matt-Gleich that is an excellent suggestion !
we could and we should easily add a solution message for this error !

this should be an easy fix ! I would be happy to review any PR that add that solution message to the error.

anyone picking up this issue, mind that this should be only for Linux and Mac platofrms and not windows.

@medyagh medyagh added needs-solution-message Issues where where offering a solution for an error would be helpful good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. labels Nov 6, 2019
@medyagh medyagh changed the title Error writing .kube/config provide solution message for file permission error for .kube/config Nov 6, 2019
@medyagh medyagh changed the title provide solution message for file permission error for .kube/config provide solution message for file permission for .kube/config Nov 6, 2019
@medyagh medyagh changed the title provide solution message for file permission for .kube/config solution message for file permission for .kube/config Nov 6, 2019
@medyagh medyagh added co/hyperkit Hyperkit related issues co/none-driver labels Nov 6, 2019
@gleich
Copy link
Author

gleich commented Nov 8, 2019

@medyagh
Super sorry for asking but I am trying to fix this and I can't seem to find where minikube is doing its error handling. Could you point me to where it is pleases?

@priyawadhwa
Copy link

Hey @Matt-Gleich looks like the writing kubeconfig error handling occurs in pkg/minikube/kubecontext/context.go. However, it happens in three functions:

  1. UnsetCurrentContext
  2. SetCurrentContext
  3. DeleteContext

I would probably update writeToFile to check if the user has permissions to write to the file. If not, then return an error suggesting the user runs the chown command.

@gleich
Copy link
Author

gleich commented Nov 16, 2019

For anyone with this issue, this fixed it for me:

chmod ugo+rwx ~/.kube/config

The command that I stated before didn't work for me when this broke again.

@tstromberg tstromberg added priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. labels Dec 9, 2019
@tstromberg tstromberg removed the needs-solution-message Issues where where offering a solution for an error would be helpful label Dec 19, 2019
@shanyang
Copy link

shanyang commented Jan 5, 2020

I have to run
sudo chown -R $USER ~/.minikube/
again on ubuntu 18.04 version, with kvm2, just FYI

@tstromberg
Copy link
Contributor

tstromberg commented Jan 8, 2020

Fixed in v1.6.2:

💣  Failed to setup kubeconfig
❌  Error: [KUBECONFIG_DENIED] Error reading file "/usr/local/google/home/tstromberg/.kube/config": open /usr/local/google/home/tstromberg/.kube/config: permission denied
💡  Suggestion: Run: 'chmod 600 $HOME/.kube/config'
⁉️   Related issues:
    ▪ https://github.com/kubernetes/minikube/issues/5714

It's worth noting that the chmod may not fix every problem, but it should at least point users to the right direction. For example, if it's an ownership issue or other ACL issue, the chmod will fail.

@kmp59
Copy link

kmp59 commented Mar 14, 2020

Screenshot from 2020-03-14 12-06-08

My issues was something like this. When I tried to access the .kube folder via terminal it gave me permission denied error. Using chown to change users didn't work. So I tried Chmod 777 and it worked.

sudo chmod 777 $HOME/.kube

@anooppb
Copy link

anooppb commented Sep 7, 2020

make it to sudo chmod 777 $HOME/.kube

@tstromberg
Copy link
Contributor

FYI: In minikube v1.13.0, the help text was updated to say:

Run: 'sudo chown $USER $HOME/.kube/config && chmod 600 $HOME/.kube/config'

@bensarifathi
Copy link

the solution is :
Run: 'sudo chown $USER $HOME/.kube && chmod 700 $HOME/.kube'
Run: 'sudo chown $USER $HOME/.kube/config && chmod 600 $HOME/.kube/config'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
co/hyperkit Hyperkit related issues co/none-driver co/virtualbox good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/ux priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants