danielfoehrKn / kubeswitch

The kubectx for operators.
https://danielfoehrkn.medium.com/the-case-of-kubeswitch-aff4b6a04ae7
Apache License 2.0
832 stars 80 forks source link

Error: the configured kubeconfig directory {"/Users/USERNAME/.kube/config" "filesystem"} does not exist #12

Closed larssb closed 3 years ago

larssb commented 3 years ago

When executing Switcher in whatever dir on my MacOS I get the following err:

Error: the configured kubeconfig directory {"/Users/USERNAME/.kube/config" "filesystem"} does not exist
the configured kubeconfig directory {"/Users/USERNAME/.kube/config" "filesystem"} does not exist

! When there is no default Kubeconfig file in the ~/.kube/ directory (meaning the config file).


So. Is it a requirement to have a default Kubeconfig config file in ~/.kube for things to work?

From reading Configure Kubeconfig stores I do not get the impression that this is the case.

I can get things to work by having whatever Kubeconfig config file in the ~/.kube/ folder. But, I'd rather not.

Looking forward to some pointers. Thank you ๐Ÿ˜„

danielfoehrKn commented 3 years ago

Hi, thanks for reporting!

Can you check if that fix works for you?

You would need to use the from source installation to test it. If it works for you I ll incorporate it in the next patch version.

larssb commented 3 years ago

I'll give it a go tomorrow. Thank you!

On Thu, Mar 4, 2021 at 4:35 PM Daniel Fรถhr notifications@github.com wrote:

Hi, thanks for reporting!

Can you check if that fix works https://github.com/danielfoehrKn/kubeswitch/commit/c6e41442f9418df16d683e51395eb557f9d60aa9for you?

You would need to use the from source installation https://github.com/danielfoehrKn/kubeswitch#from-source to test it. If it works for you I ll incorporate it in the next patch version.

โ€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/danielfoehrKn/kubeswitch/issues/12#issuecomment-790705265, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIERWWYFGJ6YJNSZKEEPUDTB6SD5ANCNFSM4YTGOYSQ .

-- Mvh. / Kind regards Lars Bengtsson

danielfoehrKn commented 3 years ago

@larssb does the issue still exist or can this issue be closed?

LarsBingBong commented 3 years ago

I'm very sorry @danielfoehrKn,

I've wanted to test this for a long long time (larssb here - just on GitHub via a comp. user). So, I still experience this issue and I don't know why.

The err.

when I execute switch or /home/linuxbrew/.linuxbrew/opt/switcher/bin/switcher >> Error: the configured kubeconfig directory "" does not exist is thrown.

Again I find that I can get rid of the err. if I put a kubeconfig file named config into the ~/.kube dir. However, even though I've specified - "~/.kube/clusters/" as the value to the paths: parameter, a file named e.g. test inside the - "~/.kube/clusters/" dir. is not found by Kubeswitch. What am I misunderstanding?

Debug

.kube folder contents

ls -la gives:

ls -la ~/.kube/
total 20
drwxr-xr-x  4 linuxlars linuxlars 4096 Aug 30 12:35 .
drwxr-xr-x 14 linuxlars linuxlars 4096 Aug 30 12:35 ..
drwxr-xr-x  2 linuxlars linuxlars 4096 Aug 30 12:33 clusters
-rw-r--r--  1 linuxlars linuxlars  151 Aug 30 12:32 switch-config.yaml
drwxr-xr-x  2 linuxlars linuxlars 4096 Aug 30 11:47 switch-state

switch-config.yaml contents

kind: SwitchConfig
version: v1alpha1
kubeconfigName: "*"
hooks: []
kubeconfigStores:
- id: default
  kind: filesystem
  paths:
  - "~/.kube/clusters/"

Regarding the patch

I'm not 100 percent. But, to me it looks like the patch you mention has been merged into master and thereby, as I run v0.4.6 of Kubeswith I should be good in this regard. The err. message is also a tad different from the one I got back in March 21.

Am I right or do I still need to try out the patch by using the source installation method.


Thank you very much - and I'm looking forward to hear from you.

LarsBingBong commented 3 years ago

@danielfoehrKn what is your take on this is I may.

Thank you ๐Ÿฅ‡

danielfoehrKn commented 3 years ago

Hi @LarsBingBong thank again for reporting such a detailed issue.

when I execute switch or /home/linuxbrew/.linuxbrew/opt/switcher/bin/switcher >> Error: the configured kubeconfig directory "" does not exist is thrown.

I could reproduce that and pushed a fix that you could try out by installing it from source (just follow the instructions on the readme. Not more than git clone & make build-switcher and then move the binary to your path). EDIT: I published release 0.4.7 that contains the fix.

However, even though I've specified - "~/.kube/clusters/" as the value to the paths: parameter, a file named e.g. test inside the - "~/.kube/clusters/" dir. is not found by Kubeswitch. What am I misunderstanding?

I used your configuration file and created the ~/.kube/clusters/" directory with a valid kubeconfig with name test. Using the kubeswitch version 0.4.6 like you. The kubeconfig was always found - I somehow cannot reproduce the issue :(

Is there an error or are the kubeconfig contexts just not found?

Things to look for

LarsBingBong commented 3 years ago

Hi @danielfoehrKn,

Thank you very much - I'm of the idea that the more details I provide the easier the fix.

What the dang! I did some more troubleshooting based on the info you provided in your latest answer. And I have to admit that I've been the greatest of n00b's on this one. I was installing kubeswitch by way of download the binary and moving it to the /usr/local/bin folder. However, as I'm no longer - wisely so - not running as sudo on my Linux box - I had to run that install script for installing kubeswitch as sudo - but that then resulted in kubeswitch getting installed at an incorrect user scope. So I read the docs again and I'm now using the brew installation method.

Everything seems to work now.

I'm sorry for having basically almost wasted your time (I say almost because this fix is great).

Bare with me and have a great day - I think this one can be closed as solved.

larssb commented 3 years ago

Pointing to the latest comment from my comp. GitHub acc. I'll hereby close the issue.