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

MacOS not loading from ~/.kube/config #417

Open
james-s-w-clark opened this issue Jan 15, 2024 · 13 comments
Open

MacOS not loading from ~/.kube/config #417

james-s-w-clark opened this issue Jan 15, 2024 · 13 comments

Comments

@james-s-w-clark
Copy link

james-s-w-clark commented Jan 15, 2024

Describe the bug

  • kdash presents the application fine, but shows Error:

Unable to obtain Kubernetes client. failed to infer config: in-cluster: (failed to read an incluster environment variable: environment variable not found), kubeconfig: (failed to determine currrent context)

Have to make my terminal tiny to see the whole error. After a few seconds, it changes to:

channel closed

  • Also tried with Exported KUBE_CONFIG, KUBECONFIG, kubeconfig, KUBE_CONFIG_PATH as ~/.kube/config in ~/.zshrc, and ran source ~/.zshrc

On the other hand, k9s loads from ~/.kube/config just fine.

I can't see documentation on what setup is required for MacOS.
I tried the Docker command, but get the same error. The only difference is that docker and docker-compose are now "Not found" in the CLI Info tab, for the docker container.

Expected behavior
MacOS should load from ~/.kube/config by default, like k9s

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • macOS 14.2.1
  • iTerm, 3.4.23
  • zsh, 5.9
  • ? Kubectl Client Version [e.g. 1.19]
    • kubernetes-cli 1.29.0
    • kubectl version --client 1.28.2, Kustomize v5.0.4-0.202....
    • Retried with binary kubectl install, to /usr/local/bin/kubectl - still not detected inside kdash
      • Same for only having fresh Homebrew kubectl install
  • ? Kubectl Server Version [e.g. 1.19]
    • kubernetes-cli 1.29.0
  • KDash version 0.4.6, installed with Homebrew

Note: kubectl client, kubectl server are Not found from brew-installed kdash

@deepu105
Copy link
Contributor

Hi, i'm having difficulty reproducing this, can you please share more info

Mac Architecture (M1 arm64 or Intel)

@james-s-w-clark
Copy link
Author

james-s-w-clark commented Jan 19, 2024

@deepu105 M1 Pro


Similar on Intel i7, 2019 Mac Pro.
Using brew installs of both the apps:

➜  ~ kdash --version
kdash 0.4.8
➜  ~ kubectl version --output=yaml
clientVersion:
  buildDate: "2023-05-17T14:20:07Z"
  compiler: gc
  gitCommit: 7f6f68fdabc4df88cfea2dcf9a19b2b830f1e647
  gitTreeState: clean
  gitVersion: v1.27.2
  goVersion: go1.20.4
  major: "1"
  minor: "27"
  platform: darwin/amd64
kustomizeVersion: v5.0.1
image

@deepu105
Copy link
Contributor

Thats strange. I tried on an M1 mac and it works fine. Was kubectl also installed using brew?

@james-s-w-clark
Copy link
Author

james-s-w-clark commented Jan 19, 2024

Yeah, tried brew and manual shell install too, same result.

Any other info I can give to help debug?


On Windows:

PS C:\Windows\system32> kubectl version
Client Version: v1.29.0
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.

PS C:\Windows\system32> kdash --version
kdash 0.4.8

Is this what we expect?
image

@deepu105
Copy link
Contributor

Given you are seeing issues in all platforms I'm wondering if there is something to do with the way your environments are set up. I'm unfortunately unable to debug since I'm unable to reproduce this. Are you able to clone the repo and debug this in VsCode?

@deepu105
Copy link
Contributor

I'm going to build a new feature allowing users to debug the app easily and provide the logs. #424

Hopefully that will help to solve this issue

@james-s-w-clark
Copy link
Author

I'm going to build a new feature allowing users to debug the app easily and provide the logs. #424

Hopefully that will help to solve this issue

Thanks, I'll happily try that out. I can try and run with debug too, just need to find the time for it :)

@deepu105
Copy link
Contributor

I pushed a version (0.6) with debug mode, can you tray and provide me the log kdash -d=debug

@james-s-w-clark
Copy link
Author

james-s-w-clark commented Jan 26, 2024

Here is what I have seen with --debug, nice feature btw :)

22:15:14 [INFO] Debug mode is enabled. Level: Info, KDash version: 0.6.0
22:15:14 [INFO] Starting network thread
22:15:14 [INFO] Starting cmd runner thread
22:15:14 [INFO] Starting network stream thread
22:15:14 [INFO] Starting UI
22:15:14 [INFO] env KUBECONFIG: Some("/Users/idiosapps/.kube/config")
22:15:14 [WARN] Getting kubernetes client by inference. No context given
22:15:14 [INFO] env KUBECONFIG: Some("/Users/idiosapps/.kube/config")
22:15:14 [WARN] Getting kubernetes client by inference. No context given
22:15:14 [INFO] Caching all resource data
22:15:14 [INFO] Cmd event received: GetCliInfo
22:15:14 [ERROR] Unable to obtain Kubernetes client. failed to infer config: in-cluster: (failed to read an incluster environment variable: environment variable not found), kubeconfig: (failed to determine current context)

Caused by:
    failed to determine current context
22:15:14 [ERROR] Unable to obtain Kubernetes client. failed to infer config: in-cluster: (failed to read an incluster environment variable: environment variable not found), kubeconfig: (failed to determine current context)

Caused by:
    failed to determine current context
22:15:19 [INFO] Input event received: KeyEvent { code: Char('c'), modifiers: KeyModifiers(CONTROL), kind: Press, state: KeyEventState(0x0) }
22:15:19 [INFO] Shutting down

Here is a snippet of my $HOME/.kube/config:

apiVersion: v1
clusters:
- cluster:
    server: https://my-kube-api.foo.bar
  name: my-kube-api
contexts:
- context:
    cluster: my-kube-api
    user: idiosapps
  name: my-kube-api
kind: Config
users:
- name: idiosapps
  user:
    token: my-token

Is there something I should run with kubectl to set the context/"in-cluster"?
I pretty much always use k9s, so I don't do kubectl set-context my-kube-api or whatever - the entry screen of k9s is choosing a context.
Looking at the UI in the readme, I don't see a Context tab on the bottom pane - but I do see All Contexts <C> at the top. I assumed it'd be similar behaviour to k9s - point the context, namespace, etc. inside k9s/kdash.

@deepu105
Copy link
Contributor

I think it could be because of not having a default context. What happens if you set a context using kubectl and then try Kdash?

Also can you provide your full kube/config file after removing anything sensitive and private so I can try to reproduce? Coz i think it could be a problem parsing your config file

@james-s-w-clark
Copy link
Author

james-s-w-clark commented Jan 29, 2024

kubectl config set-context my-kube-api
Still fails with the same error

Caused by:
    failed to determine current context

BUT good news! With:
kubectl config use-context my-kube-api
It sees the kubectl client & kubectl server, and lists all the pods, namespaces, contexts, etc.

As a new user of kdash and a previous user of k9s, this did confuse me. I thought, given that I can view and select a Context in kdash, it would be OK to just choose in the app.


Possible issue:
In the Contexts screen, I am pressing Enter on a blue context with the => to show it's selected. But, my context isn't changing from the current yellow one.
Edit: It did, about 3 minutes later 🤔


Possible improvement:
I changed the namespace to one I'm interested in, and the pods filtered correctly. But, I had to scroll down many namespaces to find it. Is there a way to text-filter? In k9s I can press / and then type what I want to find, which is super convenient.


Possible issue:
Also, it can be slow to filter the Resources (Pods). I can select a namespace and then it takes about a minute to filter down from thousands to single-digit pods.


Possible improvement:
Pods -> Containers -> Logs seems to just tail. Is it possible to review last 5/10/15 minutes of logs?


I'm happy to split those into new issues, but they might be user error. Wanted to check here first.

Really looking forward to a lighter & faster tool to interact with the clusters :) Thanks @deepu105!

@deepu105
Copy link
Contributor

deepu105 commented Feb 1, 2024

I will look into replicating the k9s behaviour for contexts. It does make sense. Could you open seperate issues for the other stuff please.

@james-s-w-clark
Copy link
Author

I have opened separate issues :) Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants