mayastor
mayastor copied to clipboard
kubectl-mayastor: use namespace from current context
Describe the bug
When using the plugin, it currently ignores the namespace from current context. You have to use -n
To Reproduce
Install mayastor in namespace not mayastor, like "openebs" e.g.
Running kubectl mayastor get volumes
will fail, even when current context has the correct namespace (with kubie for example)
Expected behavior use the context :)
What should the behaviour be like? For example, we default to the mayastor namespace so that users don't have to specify -n mayastor. If we take the namespace from context, then which one to use at any given time?
Potential approaches:
- If no rest is found on given namespace, try the context?
- If context is not "default" then always use context
- Don't default to mayastor, just use whatever the context has.
I'd probably lean towards 2 or 3, perhaps 2. Open to comments here.
If context is not "default" then always use context
Is this identifiable cleanly? context name can be potentially anything.
3 seems reasonable. Don't default to mayastor, just use whatever the context has, IF it has any namespace explicitly mentioned
What should the behaviour be like? For example, we default to the mayastor namespace so that users don't have to specify -n mayastor. If we take the namespace from context, then which one to use at any given time?
Potential approaches:
- If no rest is found on given namespace, try the context?
- If context is not "default" then always use context
- Don't default to mayastor, just use whatever the context has.
I'd probably lean towards 2 or 3, perhaps 2. Open to comments here.
I think 3 would be the best way here, as the one set to the context is usually deemed to be default for that context, so we can go with that, instead of using mayastor as hardcoded default?
Is this identifiable cleanly? context name can be potentially anything.
Yes I think we'd use current context and also take optional context name. This might require modifying e2e tests, CC @blaisedias
Also this is also a breaking change for the users, if they were not specifying the namespace and have code/scripts :(
I've discussed this with @niladrih and here's the proposal: Implement 3, but default to 2 (using cli arg or env) When we move mayastor to v3 then we can remove the cli arg/env, and default to 3.