vmware-tanzu / tanzu-framework

Tanzu Framework provides a set of building blocks to build atop of the Tanzu platform and leverages Carvel packaging and plugins to provide users with a much stronger, more integrated experience than the loose coupling and stand-alone commands of the previous generation of tools.
Apache License 2.0
196 stars 193 forks source link

`tanzu package` (and possibly other commands) do not respect namespace in kubeconfig #1351

Open evankanderson opened 2 years ago

evankanderson commented 2 years ago

Bug description

If you set your kubeconfig context like so:

kubectl config set-context --current --namespace somewhere

Running commands like tanzu package installed without a --namespace option will operate on the default namespace, rather than the somewhere namespace. This means that for long sequences / scripts, you need to repeat the --namespace argument every time.

Affected product area (please put an X in all that apply)

Expected behavior

tanzu package (and other plugins) respect the namespace in the KUBECONFIG the same way that they respect the auth and cluster address there.

Steps to reproduce the bug

Run the following on a TKG cluster:

$ kubectl config set-context --current --namespace tkg-system
$ tanzu package installed list
<no output>
$ kubectl get pkgi
<list of TKG packages installed>

Version (include the SHA if the version is not obvious)

0.10.0

Environment where the bug was observed (cloud, OS, etc)

TCE

Relevant Debug Output (Logs, manifests, etc)

adduarte commented 2 years ago

The use of the "default" namespace when not specified has been coded here .

adduarte commented 2 years ago

A possible approach here is to have the tanzu cli read the context from KUBECONFIG and set the namespace accordingly if it is not specified on the command line by "--namespace"

adduarte commented 2 years ago

Continuing to investigate the proposed changed. The current behavior is documented as the expected behavior in several places in the documentation. For example here, where it shows that not specifying --namespace will install the package to the "default" namespace. If we go ahead and change the behavior we might need to scrub other parts of the docs and code to make sure the 'default" namespace is not assumed when --namespace is not provided.

adduarte commented 2 years ago

The fixed proposed in https://github.com/vmware-tanzu/tanzu-framework/pull/1540 will continue to use "default" if no context is set. If the context is set the namespace define for that context will be used as default value. user can still set the namespace by using --namespace.

evankanderson commented 2 years ago

Thanks, the behavior in https://github.com/vmware-tanzu/tanzu-framework/issues/1351#issuecomment-1019918351 is exactly what I was hoping for.