ahmetb / kubectx

Faster way to switch between clusters and namespaces in kubectl
https://kubectx.dev
Apache License 2.0
17.31k stars 1.24k forks source link

[Go] kubens not working with in-cluster config #400

Open SQLExceptionPhil opened 11 months ago

SQLExceptionPhil commented 11 months ago

When using kubens with a ServiceAccount from within the cluster it isn't working. From what I saw it comes from how the config is loaded. When using the kubectl tool it uses the in-cluster configuration and given a small and incomplete config file it is also possible to change the namespace:

apiVersion: v1
clusters: null
contexts: 
  - context: 
       namespace: my-namespace
    name: my-context
current-context: "my-context"
kind: Config
preferences: {}
users: null

I think it should be possible to use the old bash version of kubens with this setup - but not the new golang version.

ahmetb commented 6 months ago

Do you remember what was the error you're seeing? I don't think we'd optimize the tool to try to make it work for in-cluster situation specifically, but if there's an easy fix we can take, we can give a shot.