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

Allow kubectl expose to be polymorphic to the source of the selector #5977

Conversation

smarterclayton
Copy link
Contributor

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.

@googlebot
Copy link

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.

@smarterclayton smarterclayton force-pushed the allow_expose_to_handle_other_resources branch from f641086 to b6dcb79 Compare March 26, 2015 14:20
// 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]",
Copy link
Contributor

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.

Copy link
Contributor Author

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{

  •   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]",

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

Copy link
Contributor Author

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{

  • 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]",

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

Copy link
Contributor Author

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{

  •   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]",

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

@smarterclayton smarterclayton force-pushed the allow_expose_to_handle_other_resources branch from b6dcb79 to 086081d Compare March 26, 2015 18:21
@@ -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
Copy link
Contributor

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.

Copy link
Contributor Author

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 controller

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.

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.
@smarterclayton smarterclayton force-pushed the allow_expose_to_handle_other_resources branch from 086081d to 64f91f7 Compare March 26, 2015 18:36
switch l := len(args); {
case l == 2:
resource, name = args[0], args[1]
default:
Copy link
Contributor

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

@j3ffml
Copy link
Contributor

j3ffml commented Mar 26, 2015

LGTM. Trappable is green, nit inconsequential. Merging.

j3ffml added a commit that referenced this pull request Mar 26, 2015
…ther_resources

Allow `kubectl expose` to be polymorphic to the source of the selector
@j3ffml j3ffml merged commit 653b7e6 into kubernetes:master Mar 26, 2015
kbeecher pushed a commit to endocode/kubernetes that referenced this pull request Apr 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants