k9s: Access denied after context switch




Describe the bug If I start K9s everything works fine with the current context, but if I switch the context via K9s the view stays empty.

ERR  Watcher failed for v1/pods  error="[list watch] access denied on resource \"\":\"v1/pods\""

If I exit K9s switch context via kubectl and then enter K9s again. All resources are being displayed correctly.

To Reproduce Steps to reproduce the behavior:

  1. Go to K9s
  2. Switch context
  3. See error in log

Expected behavior The resources are shown correctly after context switch.

Versions (please complete the following information):

  • OS: Windows
  • K9s: 0.25.7
  • K8s: 1.20.5

Additional context This does not happen if I switch to Kind and back. Only if I switch contexts of external Clusters.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (4 by maintainers)

Most upvoted comments

thx @Doofus100500. I dunno if this was the root cause for me but after explicitly adding a namespace to my kubectl context I now am no longer having the issue.

kubectl config set-context --current --namespace=default

I’m having this issue with v0.27.3. I’m on macos 12.6 with kubectl 1.25.2. I don’t recall switching context to trigger the error though. Also, I’m not finding how to provide the verbose logging as others have. Attempting to execute k9s -l debug will result in the error message and the Usage text (which i’ve trimmed down below):

➜  ~ k9s -l debug
Error: [list watch] access denied on resource "":"v1/pods"
Usage:
  k9s [flags]
  k9s [command]

... output trimmed for brevity

➜  ~ 

The error initially occurred while using the previous version. I first updated to v0.27.3 then uninstalled and re-installed without success.

I meet the same issue.

I see this in two ways

  • First, the wrong namespace is used
  • Second, the current k8s token does not have access to the default namespace

we can try to kubectl get pods -n xxx, confirm xxx can access and use k9s -n xxx to Specify namespce

@egvimo Let’s see if it’s still happening on v0.25.10. If not please reopen. Tx!