kubeswitch icon indicating copy to clipboard operation
kubeswitch copied to clipboard

Unable to fetch namespaces

Open jeanfrancoisgratton opened this issue 6 months ago • 2 comments

First off, I must be doing something wrong....

In my .zshrc, I export KUBECONFIG dynamically, this way: export KUBECONFIG="$(printf '%s\n' ~/.kube/configs/*.k8sconfig 2>/dev/null | awk '{printf "%s:", $0}' | sed 's/:$//')" 2>/dev/null

This allows my variable to be up-to-date at each start of my shell, regardless of the contents in ~/.kube/configs/ . All of my kube config files have the .k8sconfig extension.

My switch-config.yaml file is this: kind: SwitchConfig version: v1alpha1 kubeconfigStores:

  • kind: filesystem showPrefix: false kubeconfigName: "*.k8sconfig" paths:
    • ~/.kube/configs

The problem I have right now is that I can select a context, but once done, if I come back with ks ns it breaks with the following error: WARN[0000] failed to retrieve current namespaces: unable to create rest config: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable

Why is that, and how may I correct my setup ? Obviously I am missing something.

I currently have 2 config files in .kube/configs, but it will soon grow. I've tried exporting KUBECONFIG= one of those files. What happens then is that when I run switcher, it lists the contexts from KUBECONFIG, and then the contexts from the 2 files in .kube/configs/ .. This means one file is listed twice.

Moreover, regardless of which context I choose, when it exits and then I try switcher ns, regardless of which config file switch to, switcher ns will always lists the namespaces from the first selected file. As if my selection is disregarded past the first occurence.

jeanfrancoisgratton avatar Jan 10 '24 19:01 jeanfrancoisgratton