-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Allow kubectl expose
to be polymorphic to the source of the selector
#5977
Allow kubectl expose
to be polymorphic to the source of the selector
#5977
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA) at https://cla.developers.google.com/. If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check the information on your CLA or see this help article on setting the email on your git commits. Once you've done that, please reply here to let us know. If you signed the CLA as a corporation, please let us know the company's name. |
f641086
to
b6dcb79
Compare
// Create a service for a replicated streaming application on port 4100 balancing UDP traffic and named 'video-stream'. | ||
$ kubectl expose streamer --port=4100 --protocol=udp --service-name=video-stream` | ||
) | ||
|
||
func (f *Factory) NewCmdExposeService(out io.Writer) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "expose NAME --port=port [--protocol=TCP|UDP] [--container-port=number-or-name] [--service-name=name] [--public-ip=ip] [--create-external-load-balancer=bool]", | ||
Use: "expose [RESOURCE] NAME --port=port [--protocol=TCP|UDP] [--container-port=number-or-name] [--service-name=name] [--public-ip=ip] [--create-external-load-balancer=bool]", |
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.
My take is that if the command is going to be polymorphic to either rc or service, it should require explicitly providing the resource type. Remembering that the resource defaults to rc if omitted is an unnecessary burden for users.
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.
Isn't it going to be the default option? I would say that you expose a replication controller by default. You can expose other things. Although I guess a pod is also something you would expose (except you can't expose just one safely without doing a label query first). I'm ok with forcing someone to always type RC though.
----- Original Message -----
// Create a service for a replicated streaming application on port 4100
balancing UDP traffic and named 'video-stream'.
$ kubectl expose streamer --port=4100 --protocol=udp
--service-name=video-stream`
)func (f *Factory) NewCmdExposeService(out io.Writer) *cobra.Command {
cmd := &cobra.Command{
[--container-port=number-or-name] [--service-name=name] [--public-ip=ip]Use: "expose NAME --port=port [--protocol=TCP|UDP]
[--create-external-load-balancer=bool]", [--container-port=number-or-name] [--service-name=name] [--public-ip=ip]Use: "expose [RESOURCE] NAME --port=port [--protocol=TCP|UDP]
[--create-external-load-balancer=bool]",My take is that if the command is going to be polymorphic to either rc or
service, it should require explicitly providing the resource type.
Remembering that the resource defaults to rc if omitted is an unnecessary
burden for users.
Reply to this email directly or view it on GitHub:
https://github.com/GoogleCloudPlatform/kubernetes/pull/5977/files#r27234846
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.
I erred on the side of not breaking the input pattern of existing commands. We probably want to break CLI before 1.0. If we don't think a default is valuable let's just change it now.
----- Original Message -----
Isn't it going to be the default option? I would say that you expose a
replication controller by default. You can expose other things. Although
I guess a pod is also something you would expose (except you can't expose
just one safely without doing a label query first). I'm ok with forcing
someone to always type RC though.----- Original Message -----
// Create a service for a replicated streaming application on port 4100
balancing UDP traffic and named 'video-stream'.
$ kubectl expose streamer --port=4100 --protocol=udp
--service-name=video-stream`
)func (f *Factory) NewCmdExposeService(out io.Writer) *cobra.Command {
cmd := &cobra.Command{
[--container-port=number-or-name] [--service-name=name] [--public-ip=ip]Use: "expose NAME --port=port [--protocol=TCP|UDP]
[--create-external-load-balancer=bool]", [--container-port=number-or-name] [--service-name=name] [--public-ip=ip]Use: "expose [RESOURCE] NAME --port=port [--protocol=TCP|UDP]
[--create-external-load-balancer=bool]",My take is that if the command is going to be polymorphic to either rc or
service, it should require explicitly providing the resource type.
Remembering that the resource defaults to rc if omitted is an unnecessary
burden for users.
Reply to this email directly or view it on GitHub:
https://github.com/GoogleCloudPlatform/kubernetes/pull/5977/files#r27234846
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.
Fixed ptal
----- Original Message -----
I erred on the side of not breaking the input pattern of existing commands.
We probably want to break CLI before 1.0. If we don't think a default is
valuable let's just change it now.----- Original Message -----
Isn't it going to be the default option? I would say that you expose a
replication controller by default. You can expose other things.
Although
I guess a pod is also something you would expose (except you can't expose
just one safely without doing a label query first). I'm ok with forcing
someone to always type RC though.----- Original Message -----
// Create a service for a replicated streaming application on port
4100
balancing UDP traffic and named 'video-stream'.
$ kubectl expose streamer --port=4100 --protocol=udp
--service-name=video-stream`
)func (f *Factory) NewCmdExposeService(out io.Writer) *cobra.Command {
cmd := &cobra.Command{
[--container-port=number-or-name] [--service-name=name]Use: "expose NAME --port=port [--protocol=TCP|UDP]
[--public-ip=ip]
[--create-external-load-balancer=bool]", [--container-port=number-or-name] [--service-name=name]Use: "expose [RESOURCE] NAME --port=port [--protocol=TCP|UDP]
[--public-ip=ip]
[--create-external-load-balancer=bool]",My take is that if the command is going to be polymorphic to either rc or
service, it should require explicitly providing the resource type.
Remembering that the resource defaults to rc if omitted is an unnecessary
burden for users.
Reply to this email directly or view it on GitHub:
https://github.com/GoogleCloudPlatform/kubernetes/pull/5977/files#r27234846
b6dcb79
to
086081d
Compare
@@ -16,8 +16,9 @@ kubectl expose \- Take a replicated application and expose it as Kubernetes Serv | |||
Take a replicated application and expose it as Kubernetes Service. | |||
|
|||
.PP | |||
Looks up a ReplicationController by name, and uses the selector for that replication controller | |||
as the selector for a new Service on the specified port. | |||
Looks up a replication controller by name, and uses the selector for that replication controller |
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.
Wording a bit clunky. Consider changing to
Looks up a replication controller or service by name, and uses the selector for that
resource as the selector for a new service on the specified port.
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.
Done
----- Original Message -----
@@ -16,8 +16,9 @@ kubectl expose - Take a replicated application and
expose it as Kubernetes Serv
Take a replicated application and expose it as Kubernetes Service..PP
-Looks up a ReplicationController by name, and uses the selector for that
replication controller
-as the selector for a new Service on the specified port.
+Looks up a replication controller by name, and uses the selector for that
replication controllerWording a bit clunky. Consider changing to
Looks up a replication controller or service by name, and uses the selector for that resource as the selector for a new service on the specified port.
Reply to this email directly or view it on GitHub:
https://github.com/GoogleCloudPlatform/kubernetes/pull/5977/files#r27241736
Allows exposing new resource types to be exposed (OpenShift deployment controllers, copying services, and other resources that will have pod label selectors). Also fixed a bug where the selector wasn't exposed because of parameter defaulting.
086081d
to
64f91f7
Compare
switch l := len(args); { | ||
case l == 2: | ||
resource, name = args[0], args[1] | ||
default: |
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.
Nit: seems like if/else would be cleaner
LGTM. Trappable is green, nit inconsequential. Merging. |
…ther_resources Allow `kubectl expose` to be polymorphic to the source of the selector
Allows exposing new resource types to be exposed (OpenShift deployment
controllers, copying services, and other resources that will have
pod label selectors).
Also fixed a bug where the selector wasn't exposed because of parameter
defaulting.