knuu icon indicating copy to clipboard operation
knuu copied to clipboard

Use namespace from context as default kubernetes namespace

Open smuu opened this issue 2 years ago • 1 comments

Currently, the namespace is test if not specified otherwise, using the KNUU_NAMESPACE environment variable.

See here in the code:

https://github.com/celestiaorg/knuu/blob/main/pkg/k8s/k8s.go#L43

Instead of using test as default, it knuu should use the namespace selected in the kubeconfig if the environment variable KNUU_NAMESPACE is not set.

smuu avatar Jul 11 '23 08:07 smuu

Hey @smuu , changing the L41-48

else {
		// Read the namespace from KNUU_NAMESPACE environment variable
		if os.Getenv("KNUU_NAMESPACE") != "" {
			setNamespace(os.Getenv("KNUU_NAMESPACE"))
		} else {
			setNamespace("test")
		}
	}

with

else {
		// Read the namespace from the kubeconfig file
		namespace, err := clientcmd.NewDefaultClientConfigLoadingRules().Namespace()
		if err != nil {
			return fmt.Errorf("retrieving namespace from kubeconfig: %w", err)
		} else{
			setNamespace(namespace)
		}
	}

will resolve the issue . Please confirm this.

baibhavKumar1 avatar Jul 12 '23 18:07 baibhavKumar1

We have scopes now

smuu avatar Jul 04 '24 14:07 smuu