kdash-rs / kdash

A simple and fast dashboard for Kubernetes
https://kdash.cli.rs
MIT License
2.06k stars 78 forks source link

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

Open james-s-w-clark opened 7 months ago

james-s-w-clark commented 7 months ago

Describe the bug

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

channel closed

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):

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

deepu105 commented 7 months ago

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

Mac Architecture (M1 arm64 or Intel)

james-s-w-clark commented 7 months ago

@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 commented 7 months ago

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

james-s-w-clark commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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

james-s-w-clark commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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