-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Kubectl namespace support #1941
Conversation
Tests? |
Added test for getting namespace information from disk. |
6abdb46
to
2781dbb
Compare
Instead of a separate subcommand and file on disk for this info, I think this shows we are overdue for a kubectl config command. See #1755 (comment) for more info and imagine using |
I don't know that I consider 'git config' to be the right experience here. If you're switching contexts, that's not just a single config flag, it's a whole stack of behaviors. Swapping between those is a contextual action - how does config make it better? ----- Original Message -----
|
Maybe we need a If we implement #1755, then when I'm using kubectl, I've likely done some command like This all needs to be designed and implemented, so this PR is probably good for now, but I would just expect the internal behavior (and possibly some of the external behavior) to change when we sort out all the config stuff. |
Using namespace default | ||
|
||
$ kubectl namespace other | ||
Using namespace other`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if there was some slightly different language for when the namespace is set vs is just being displayed. Since "default" is the namespace used when none is provided, it's not entirely clear that kubectl namespace
Using namespace default
isn't actually also setting it to default/clearing the value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I will make an update.
Sent from my iPhone
On Oct 22, 2014, at 3:18 PM, Sam Ghods notifications@github.com wrote:
In pkg/kubectl/cmd/namespace.go:
+)
+
+func NewCmdNamespace(out io.Writer) *cobra.Command {
- cmd := &cobra.Command{
Use: "namespace [<namespace>]",
Short: "Set and view the current Kubernetes namespace",
Long: `Set and view the current Kubernetes namespace scope for command line requests.
+A Kubernetes namespace subdivides the cluster into groups of logically related pods, services, and replication controllers.
+
+Examples:- $ kubectl namespace
- Using namespace default
- $ kubectl namespace other
- Using namespace other`,
It would be nice if there was some slightly different language for when the namespace is set vs is just being displayed. Since "default" is the namespace used when none is provided, it's not entirely clear that kubectl namespace Using namespace default isn't actually also setting it to default/clearing the value.—
Reply to this email directly or view it on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this get addressed?
Completely agree on need to consolidate on disk storage when that command is available. Sent from my iPhone
|
That I agree with - like Git, there are certain config levels that make sense (global, user, repo) but unlike Git one config repository needs to handle multiple repositories of config (namespaces). Perhaps global config, per-server config, and per-namespace config are all relevant, with user config being less relevant.
|
d659f25
to
a6a3632
Compare
Differentiated message on set namespace versus viewing the current. |
@@ -63,11 +63,11 @@ func Modify(w io.Writer, c *client.RESTClient, action ModifyAction, data []byte) | |||
var id string | |||
switch action { | |||
case "create": | |||
id, err = doCreate(c, resource, data) | |||
id, err = doCreate(c, namespace, resource, data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the data already has "namespace" set? Who wins? I am not so enthused about special-casing this one field, except in cases like GET where there is no input already. Allowing people (encouraging really) to rely on the environmental definition of namespace feels sketchy to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the data already has a namespace set, and you post to a URL for an alternate namespace, the server properly rejects the request and states that the namespace in the data does not match the namespace of the request.
I very much like the idea of "kubectl config", but I agree that it needs some real design work. I'm wary of this PR, partly because we haven't done that design work. |
@thockin - see my previous comment if that is related to your wariness, but this is bringing the same ability we delivered to kubecfg and had specified in the namespaces.md design document. Even in the presence of kubectl config, I think we will want this command. |
a6a3632
to
d86e9fa
Compare
Rebased |
Sorry for not paying attention. What do we expect to be in NamespaceInfo soon? Right now, it's just namespace, in which case this is overkill and we should just accept namespace from environment variable and command-line flag. |
I'll make the case that namespace (and context) is as or more important to get right in client tools. The pattern we're building off of is ensuring the user makes an explicit choice to set a default context instead of requiring it on every call. It's not absolutely required to deliver this, but in practice i feel this is the bare minimum to make an acceptable user experience for end users who approach the tools day to day. The problem with environment only is that it can lead to unexpected and ambiguous behavior - forget to set an env and you can destroy a production cluster. To me, namespace is as important as the current directory is to git in terms of clearly communicating scope. Unfortunately the shell handles that scope for Git by default (the prompt is a powerful additional tool, as evidenced by common git to shell integration, that env could also be integrated with). Derek and I can make a more structured argument in detail for this.
|
I guess I thought the CLI for namespaces was the least controversial aspect of the overall proposal. I echo what Clayton said, but I will elaborate that NamespaceInfo is not expected to grow, but we anticipate it moving into a central style config file similar to git-config. @erictune any input here? I think our perspective is different in that we anticipate rarely operating in the "default" namespace, and it will be the norm for our end users to switch namespace contexts. Given this an environment variable is really annoying in the same way specifying a -b argument to every git operation would be a pain if you were not on master. Sent from my iPhone
|
Which is considered more important at this point, making it possible to specify the namespace or getting the CLI config mechanism in place? Would you like this PR to be reviewed for one, the other, or both of these issues? |
I will comment further on config in #1755. |
@bgrant0607, I would like this PR reviewed as a mechanism to specify the namespace and not the general purpose CLI config mechanism. I think the operation as specified can remain unchanged, and the general purpose CLI config mechanism can move the persistence of the information to a centralized location at the same time it moves persistence of the authentication info. We have downstream use cases where this is important to us in the near term. |
Just a reminder, this is migrating a feature that is in kubecfg today, but was not completed when kubectl was initially integrated. I need to get kubectl functionally equivalent.
|
Ok, this is fine by me pending the one point about distinguishing getting vs. setting in output. We can defer the config overhaul of all similar persistent flags to #1755. |
d86e9fa
to
88277b5
Compare
The update to distinguish between setting and viewing current namespace has been made.
Thanks all. |
LGTM |
Pls. squash commits |
Add unit test for load namespace info Different message on display of namespace versus setting namespace
88277b5
to
5a7aced
Compare
@bgrant0607 squashed. |
@derekwaynecarr Would you be willing to update namespaces.md to refer to kubectl rather than kubecfg? |
Sure, no problem. Sent from my iPhone
|
CFE-910: bump library-go
Added support for setting a namespace for kubectl requests.
FYI @ghodss