Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have the Velero CLI use the active namespace in the current context #3194

Open
carlisia opened this issue Dec 16, 2020 · 17 comments
Open

Have the Velero CLI use the active namespace in the current context #3194

carlisia opened this issue Dec 16, 2020 · 17 comments
Labels
Area/CLI related to the command-line interface Enhancement/User End-User Enhancement to Velero Good first issue Looking to contribute to Velero? Issues with this label might be a great place to start! Help wanted kind/requirement Reviewed Q2 2021

Comments

@carlisia
Copy link
Contributor

I thought we had an issue for this but couldn't find it.

Currently, the Velero CLI uses the velero namespace in the current context, unless otherwise specified. This means that if you are operating under a namespace other than velero, you have to specify the namespace with every single command.

As it is common with other tools, invert things and make it so Velero recognizes and uses the active namespace, unless otherwise specified.

Vote on this issue!

This is an invitation to the Velero community to vote on issues, you can see the project's top voted issues listed here.
Use the "reaction smiley face" up to the right of this comment to vote.

  • 👍 for "The project would be better with this feature added"
  • 👎 for "This feature will not enhance the project in a meaningful way"
@carlisia carlisia added Enhancement/User End-User Enhancement to Velero Area/CLI related to the command-line interface labels Dec 16, 2020
@carlisia carlisia added Help wanted Good first issue Looking to contribute to Velero? Issues with this label might be a great place to start! labels Dec 16, 2020
@nrb
Copy link
Contributor

nrb commented Dec 16, 2020

You can use velero client config set namespace <namespace>, but this doesn't tie it to a Kubeconfig context currently.

We could perhaps expand the config to take a context -> namespace mapping.

@shawn-hurley
Copy link
Contributor

Hello all,

I think I am interested in taking this issue on if no one is working on it?

@carlisia
Copy link
Contributor Author

It's yours! Thank you. Just make sure that users can override that with the existing global flag --namespace.

@shawn-hurley
Copy link
Contributor

I just want to make sure that I am doing the right thing here because I am wondering if this is breaking change.

This means that unless otherwise specified we will use the context name, and will never use the velero namespace by default or the namespace defined in VELERO_NAMESPACE env var?

@carlisia
Copy link
Contributor Author

Ok, great question. This is what I think the order of precedence should be:

  • use the namespace given in the command line
  • if the above is not passed in, use the env var
  • if not those, use whatever namespace is in context

I'd like to get a sanity check from @nrb.

@nrb
Copy link
Contributor

nrb commented Jan 26, 2021

Yep, I agree with @carlisia!

@dsu-igeek
Copy link
Contributor

So if I don't do anything my active namespace is "default", right?

If I then do "velero install" without specifying a namespace, where will it go? "default" or "velero"?

Afterwards, if I don't set an active namespace, how will this work? If I'm doing something in another namespace and then want to do a backup using Velero, I have to either switch namespaces or specify the velero namespace on the command line?

This doesn't sound right. My active namespace is where I want my kubectl commands to go to. The velero CLI is a different app, it shouldn't be going to the same place my kubectl commands go, because I'm not using kubectl, in all likelihood I'm working on a namespace that doesn't have anything to do with Velero and then I want to back something up.

Am I missing something here?

@shawn-hurley
Copy link
Contributor

I have often found that for velero backup / velero restore commands, I wish it understood my context.

The velero install is an interesting case, though.

I wonder if we should talk through this in a community meeting?

@dsu-igeek
Copy link
Contributor

I put this on the Agenda for Feb 9, if that date doesn't work, please modify the agenda and put it when it's convenient, thanks!

@nrb
Copy link
Contributor

nrb commented Feb 9, 2021

I will link this to our multitenancy epic, as there are assumptions for that tied up in this issue.

@nrb
Copy link
Contributor

nrb commented May 12, 2021

@shawn-hurley You're assigned to this, any movement?

@shawn-hurley
Copy link
Contributor

I thought that the goal was to wait to fix this or at least track this as a piece of the multitenancy work?

If there is a path forward that has been determined that I missed, then I can complete it.

Sorry if I have been behind on this discussion.

@georgettica
Copy link
Contributor

throwing this out there
https://github.com/vmware-tanzu/velero/blob/main/pkg/client/factory.go#L93
this is the location that sets the "velero" namespace if not specified with

velero client config set namespace=$NAMESPACE

I guess the logic to take the current namespace should be plopped here
unless my quick digging was wrong

@kaovilai
Copy link
Contributor

kaovilai commented Jul 1, 2022

What do people think about adding flag --velero-use-current-kubecontext or -vuck

velero -vuck backup delete --all

or --use-current-kubecontext -uckc or -ucc

@kaovilai
Copy link
Contributor

kaovilai commented Jul 1, 2022

velero client set-context-as-velero-namespace
would allow for easy context switching without having to type out the namespace.

@shawn-hurley shawn-hurley removed their assignment Oct 17, 2023
@ale-bit1
Copy link

ale-bit1 commented Mar 7, 2024

Hello, can I be helpful on this? If so, please let me know!

@kaovilai
Copy link
Contributor

kaovilai commented Mar 7, 2024

Code PRs are always welcome in this community, make the change and create PR if you have bandwidth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/CLI related to the command-line interface Enhancement/User End-User Enhancement to Velero Good first issue Looking to contribute to Velero? Issues with this label might be a great place to start! Help wanted kind/requirement Reviewed Q2 2021
Projects
None yet
Development

No branches or pull requests

9 participants